diff --git a/crates/accelerate/src/target_transpiler/nullable_index_map.rs b/crates/accelerate/src/target_transpiler/nullable_index_map.rs index 7f5f84297572..ea354a77860a 100644 --- a/crates/accelerate/src/target_transpiler/nullable_index_map.rs +++ b/crates/accelerate/src/target_transpiler/nullable_index_map.rs @@ -355,19 +355,20 @@ where V: IntoPy + FromPyObject<'py> + Clone, { fn extract_bound(ob: &Bound<'py, PyAny>) -> PyResult { - let map: IndexMap, V, RandomState> = ob.extract()?; - let mut null_val: Option = None; - let filtered = map - .into_iter() - .filter_map(|(key, value)| match (key, value) { + let mut null_val = None; + let dict_downcast: &Bound = ob.downcast()?; + let iter = dict_downcast.iter().filter_map(|(key, value)| { + let (key, value): (Option, V) = (key.extract().unwrap(), value.extract().unwrap()); + match (key, value) { (Some(key), value) => Some((key, value)), (None, value) => { null_val = Some(value); None } - }); + } + }); Ok(Self { - map: filtered.collect(), + map: iter.collect(), null_val, }) }