Skip to content

Commit 2a2fca0

Browse files
committed
Use py.NotImplemented() for unsupported cmp ops
1 parent d273516 commit 2a2fca0

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/searcher.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,16 @@ impl SearchResult {
6565
}
6666
}
6767

68-
fn __richcmp__(&self, other: &Self, op: CompareOp) -> PyResult<bool> {
68+
fn __richcmp__(
69+
&self,
70+
other: &Self,
71+
op: CompareOp,
72+
py: Python<'_>,
73+
) -> PyObject {
6974
match op {
70-
CompareOp::Eq => Ok(self == other),
71-
CompareOp::Ne => Ok(self != other),
72-
_ => Err(PyNotImplementedError::new_err(format!(
73-
"{op:?} op is not supported"
74-
))),
75+
CompareOp::Eq => (self == other).into_py(py),
76+
CompareOp::Ne => (self != other).into_py(py),
77+
_ => py.NotImplemented(),
7578
}
7679
}
7780

0 commit comments

Comments
 (0)