## std.compare: Classes for comparable types. ## reference: https://doc.rust-lang.org/std/cmp ## The Eq class. For types with some notion of equivalence. pub type Eq = class ==(Self, Self): bool ## A blanket implementation of a corresponding not-equal function. pub !=[T: Eq](a: T, b: T): bool = not(a == b) ## The Compare class. For a type comparable with itself. pub type Compare = class <(a: Self, b: Self): bool ## A blanket implementation of a corresponding greater-than function. ## Note to self: do NOT inline! pub func >[T: Compare](a: T, b: T): bool = b < a ## The Ord class. For types with some notion of equivalence and comparision. ## ## Note: This is *not* a mathematical notion of an order! ## No invariants on `<` nor `==` are guaranteed to hold, as classes ## are implicitly implementable. pub type Ord = class <(a: Self, b: Self): bool ==(a: Self, b: Self): bool ## A blanket implementation of a corresponding less-than-or-equal function. pub func <=[T: Ord](a: T, b: T): bool = a < b or a == b ## A blanket implementation of a corresponding greater-than-or-equal function. pub func >=[T: Ord](a: T, b: T): bool = a > b or a == b