Skip to content

Commit

Permalink
Use #[derive(FromPyObject)] instead of manual impl
Browse files Browse the repository at this point in the history
  • Loading branch information
FlickerSoul committed Jul 6, 2024
1 parent 6c7cdd2 commit 0c600b8
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -517,19 +517,9 @@ struct ItemsView {
inner: HashTrieMapSync<Key, PyObject>,
}

#[derive(FromPyObject)]
struct ItemViewQuery(Key, PyObject);

impl<'source> FromPyObject<'source> for ItemViewQuery {
fn extract_bound(ob: &Bound<'source, PyAny>) -> PyResult<Self> {
let tuple_bound: &Bound<'source, PyTuple> = ob.downcast()?;

let k = tuple_bound.get_item(0)?;
let v = tuple_bound.get_item(1)?;

Ok(ItemViewQuery(Key::extract_bound(&k)?, v.into_py(ob.py())))
}
}

#[pymethods]
impl ItemsView {
fn __contains__(slf: PyRef<'_, Self>, item: ItemViewQuery) -> PyResult<bool> {
Expand Down

0 comments on commit 0c600b8

Please sign in to comment.