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

Conversion from the C enum.

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.