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 Freeze for CompareOp
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more