pub struct PyComparisonOp(/* private fields */);Implementations§
Source§impl PyComparisonOp
impl PyComparisonOp
pub fn eq_only( self, f: impl FnOnce() -> PyResult<PyComparisonValue>, ) -> PyResult<PyComparisonValue>
pub fn eval_ord(self, ord: Ordering) -> bool
pub const fn swapped(self) -> Self
pub fn method_name(self, ctx: &Context) -> &'static PyStrInterned
pub const fn operator_token(self) -> &'static str
Sourcepub fn identical_optimization(
self,
a: &impl Borrow<PyObject>,
b: &impl Borrow<PyObject>,
) -> Option<bool>
pub fn identical_optimization( self, a: &impl Borrow<PyObject>, b: &impl Borrow<PyObject>, ) -> Option<bool>
Returns an appropriate return value for the comparison when a and b are the same object, if an appropriate return value exists.
Sourcepub fn eval_eq(self, equal: impl FnOnce() -> bool) -> Option<bool>
pub fn eval_eq(self, equal: impl FnOnce() -> bool) -> Option<bool>
The answer to this comparison for two operands that equal reports as
equal or not, or None for an ordering operator, which equality alone
cannot settle – equal is not called in that case.
This is what lets a type answer == and != with an equality test
rather than with an ordering: the two agree on the answer, but equality
can settle a length mismatch without looking at the contents at all.
The two neighbouring helpers answer different questions: Self::map_eq
answers only where its predicate holds, so a caller still handles the
other side, and Self::eq_only declares the comparison
NotImplemented for an ordering operator. This one leaves the ordering
operators to the caller, which is what a type with a real ordering
needs.
Trait Implementations§
Source§impl Clone for PyComparisonOp
impl Clone for PyComparisonOp
impl Copy for PyComparisonOp
Source§impl Debug for PyComparisonOp
impl Debug for PyComparisonOp
impl Eq for PyComparisonOp
Source§impl From<ComparisonOperator> for PyComparisonOp
impl From<ComparisonOperator> for PyComparisonOp
Source§fn from(op: ComparisonOperator) -> Self
fn from(op: ComparisonOperator) -> Self
Source§impl PartialEq for PyComparisonOp
impl PartialEq for PyComparisonOp
impl StructuralPartialEq for PyComparisonOp
Auto Trait Implementations§
impl Freeze for PyComparisonOp
impl RefUnwindSafe for PyComparisonOp
impl Send for PyComparisonOp
impl Sync for PyComparisonOp
impl Unpin for PyComparisonOp
impl UnsafeUnpin for PyComparisonOp
impl UnwindSafe for PyComparisonOp
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.impl<T> ErasedDestructor for Twhere
T: 'static,
impl<T> Helper for T
Source§impl<T, U> ImaginaryInto<U> for Twhere
U: ImaginaryFrom<T>,
impl<T, U> ImaginaryInto<U> for Twhere
U: ImaginaryFrom<T>,
fn imaginary_into(self) -> U
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> ⓘ
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> ⓘ
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