Search results

There are no results.

std.cmp.Compare

trait pub Compare

A type that can be compared to another type for a sort-order.

Required methods

cmp

Show source code
Hide 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 code
Hide 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 code
Hide 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 code
Hide 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 code
Hide 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

std.bool.

Bool

impl Compare for Bool
std.float.

Float

impl Compare for Float
std.int.

Int

impl Compare for Int
std.string.

String

impl Compare for String
std.time.

DateTime

impl Compare for DateTime
std.time.

Duration

impl Compare for Duration
std.time.

Instant

impl Compare for Instant