Search results

There are no results.

std.cmp.Compare

Compare[T]

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

std.bool.

Bool

impl Compare[Bool] for Bool
std.float.

Float

impl Compare[Float] for Float
std.int.

Int

impl Compare[Int] for Int
std.string.

String

impl Compare[String] for String
std.time.

DateTime

impl Compare[DateTime] for DateTime
std.time.

Duration

impl Compare[Duration] for Duration
std.time.

Instant

impl Compare[Instant] for Instant