pub trait NumCmp<Other: Copy>: Copy {
// Required methods
fn num_cmp(self, other: Other) -> Option<Ordering>;
fn num_eq(self, other: Other) -> bool;
fn num_ne(self, other: Other) -> bool;
fn num_lt(self, other: Other) -> bool;
fn num_gt(self, other: Other) -> bool;
fn num_le(self, other: Other) -> bool;
fn num_ge(self, other: Other) -> bool;
}
Expand description
A trait for comparison between differently typed numbers.
This trait is implemented for every pair of integer and floating-point types available,
including isize
, usize
and also (when the i128
feature is enabled) i128
and u128
.
Required Methods§
Sourcefn num_cmp(self, other: Other) -> Option<Ordering>
fn num_cmp(self, other: Other) -> Option<Ordering>
Same to self.partial_cmp(&other)
but can be used for different numeric types for self
and other
.
Sourcefn num_eq(self, other: Other) -> bool
fn num_eq(self, other: Other) -> bool
Same to self == other
but can be used for different numeric types for self
and other
.
Sourcefn num_ne(self, other: Other) -> bool
fn num_ne(self, other: Other) -> bool
Same to self != other
but can be used for different numeric types for self
and other
.
Sourcefn num_lt(self, other: Other) -> bool
fn num_lt(self, other: Other) -> bool
Same to self < other
but can be used for different numeric types for self
and other
.
Sourcefn num_gt(self, other: Other) -> bool
fn num_gt(self, other: Other) -> bool
Same to self > other
but can be used for different numeric types for self
and other
.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.