std.cmp.Compare
trait pub Compare
A type that can be compared to another type for a sort-order.
Required methods
cmp
Show source codeHide source code
fn pub cmp(other: ref Self) -> Ordering
fn pub cmp(other: ref Self) -> Ordering
Returns the ordering between self
and the given argument.
The returned value should be as follows:
a == b
:Ordering.Equal
a > b
:Ordering.Greater
a < b
:Ordering.Less
Default methods
<
Show source codeHide source code
fn pub <(other: ref Self) -> Bool {
match cmp(other) {
case Less -> true
case _ -> false
}
}
fn pub <(other: ref Self) -> Bool
Returns true
if self
is lower than the given argument.
<=
Show source codeHide source code
fn pub <=(other: ref Self) -> Bool {
match cmp(other) {
case Less or Equal -> true
case _ -> false
}
}
fn pub <=(other: ref Self) -> Bool
Returns true
if self
is lower than or equal to the given argument.
>
Show source codeHide source code
fn pub >(other: ref Self) -> Bool {
match cmp(other) {
case Greater -> true
case _ -> false
}
}
fn pub >(other: ref Self) -> Bool
Returns true
if self
is greater than the given argument.
>=
Show source codeHide source code
fn pub >=(other: ref Self) -> Bool {
match cmp(other) {
case Greater or Equal -> true
case _ -> false
}
}
fn pub >=(other: ref Self) -> Bool
Returns true
if self
is equal to or greater than the given argument.
Implementations
Bool
impl Compare for Bool
Float
impl Compare for Float
Int
impl Compare for Int
String
impl Compare for String
DateTime
impl Compare for DateTime
Duration
impl Compare for Duration
Instant
impl Compare for Instant