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§
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))
}
}