Skip to content

Commit

Permalink
Remove extract methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Matlock committed Oct 26, 2024
1 parent 4ff84e0 commit 4c16e4a
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 38 deletions.
5 changes: 1 addition & 4 deletions src/conversions/std/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ use crate::ToPyObject;
use crate::{
conversion::IntoPyObject,
instance::Bound,
types::{
any::PyAnyMethods, dict::PyDictMethods, mappingproxy::PyMappingProxyMethods, PyDict,
PyMappingProxy,
},
types::{any::PyAnyMethods, dict::PyDictMethods, PyDict},
FromPyObject, IntoPy, PyAny, PyErr, PyObject, Python,
};

Expand Down
34 changes: 0 additions & 34 deletions src/types/mappingproxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,6 @@ mod tests {
.get_item(8i32)
.unwrap_err()
.is_instance_of::<PyKeyError>(py));
let map: HashMap<i32, i32> = [(7, 32)].iter().cloned().collect();
assert_eq!(map, mappingproxy.extract().unwrap());
let map: BTreeMap<i32, i32> = [(7, 32)].iter().cloned().collect();
assert_eq!(map, mappingproxy.extract().unwrap());
});
}

Expand Down Expand Up @@ -321,36 +317,6 @@ mod tests {
});
}

#[test]
fn test_hashmap_to_python() {
Python::with_gil(|py| {
let mut map = HashMap::<i32, i32>::new();
map.insert(1, 1);

let dict = map.clone().into_py_dict(py).unwrap();
let py_map = PyMappingProxy::new(py, dict.as_mapping());

assert_eq!(py_map.len().unwrap(), 1);
assert_eq!(py_map.get_item(1).unwrap().extract::<i32>().unwrap(), 1);
assert_eq!(map, py_map.extract().unwrap());
});
}

#[test]
fn test_btreemap_to_python() {
Python::with_gil(|py| {
let mut map = BTreeMap::<i32, i32>::new();
map.insert(1, 1);

let dict = map.clone().into_py_dict(py).unwrap();
let py_map = PyMappingProxy::new(py, dict.as_mapping());

assert_eq!(py_map.len().unwrap(), 1);
assert_eq!(py_map.get_item(1).unwrap().extract::<i32>().unwrap(), 1);
assert_eq!(map, py_map.extract().unwrap());
});
}

#[test]
fn test_hashmap_into_python() {
Python::with_gil(|py| {
Expand Down

0 comments on commit 4c16e4a

Please sign in to comment.