std.cmp.Compare
Compare[T]
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 T) -> Ordering
fn pub cmp(other: ref T) -> 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 T) -> Bool {
match cmp(other) {
case Less -> true
case _ -> false
}
}
fn pub <(other: ref T) -> Bool
Returns true
if self
is lower than the given argument.
<=
Show source codeHide source code
fn pub <=(other: ref T) -> Bool {
match cmp(other) {
case Less or Equal -> true
case _ -> false
}
}
fn pub <=(other: ref T) -> Bool
Returns true
if self
is lower than or equal to the given argument.
>
Show source codeHide source code
fn pub >(other: ref T) -> Bool {
match cmp(other) {
case Greater -> true
case _ -> false
}
}
fn pub >(other: ref T) -> Bool
Returns true
if self
is greater than the given argument.
>=
Show source codeHide source code
fn pub >=(other: ref T) -> Bool {
match cmp(other) {
case Greater or Equal -> true
case _ -> false
}
}
fn pub >=(other: ref T) -> Bool
Returns true
if self
is equal to or greater than the given argument.
Implementations
Bool
impl Compare[Bool] for Bool
Float
impl Compare[Float] for Float
Int
impl Compare[Int] for Int
String
impl Compare[String] for String
DateTime
impl Compare[DateTime] for DateTime
Duration
impl Compare[Duration] for Duration
Instant
impl Compare[Instant] for Instant