std.cmp.Compare
trait pub CompareA 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) -> Orderingfn pub cmp(other: ref Self) -> OrderingReturns the ordering between self and the given argument.
The returned value should be as follows:
a == b:Ordering.Equala > b:Ordering.Greatera < 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) -> BoolReturns 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) -> BoolReturns 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) -> BoolReturns 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) -> BoolReturns true if self is equal to or greater than the given argument.
Implementations
Bool
impl Compare for BoolFloat
impl Compare for FloatInt
impl Compare for IntEncoding
impl Compare for EncodingVersion
impl Compare for VersionString
impl Compare for StringDateTime
impl Compare for DateTimeDuration
impl Compare for DurationInstant
impl Compare for Instant