pub enum CompareOp {
Lt = 0,
Le = 1,
Eq = 2,
Ne = 3,
Gt = 4,
Ge = 5,
}
Expand description
Operators for the __richcmp__
method
Variants§
Lt = 0
The less than operator.
Le = 1
The less than or equal to operator.
Eq = 2
The equality operator.
Ne = 3
The not equal to operator.
Gt = 4
The greater than operator.
Ge = 5
The greater than or equal to operator.
Implementations§
source§impl 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§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more