pub enum CompareOp {
Lt,
Le,
Eq,
Ne,
Gt,
Ge,
}
Expand description
Operators for the __richcmp__
method
Variants
Lt
The less than operator.
Le
The less than or equal to operator.
Eq
The equality operator.
Ne
The not equal to operator.
Gt
The greater than operator.
Ge
The greater than or equal to operator.
Implementations
sourceimpl CompareOp
impl CompareOp
sourcepub fn matches(&self, result: Ordering) -> bool
pub fn matches(&self, result: Ordering) -> bool
Returns if a Rust std::cmp::Ordering
matches this ordering query.
Usage example:
#[pyclass]
struct Size {
size: usize
}
#[pymethods]
impl Size {
fn __richcmp__(&self, other: &Size, op: CompareOp) -> bool {
op.matches(self.size.cmp(&other.size))
}
}
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for CompareOp
impl Send for CompareOp
impl Sync for CompareOp
impl Unpin for CompareOp
impl UnwindSafe for CompareOp
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more