std::cmp::Ord

Trait std::cmp::Ord

pub trait Ord: Eq + PartialOrd<Self> {
    fn cmp(&self, other: &Self) -> Ordering;
}

Trait for types that form a total order.

An order is a total order if it is (for all a, b and c):

  • total and antisymmetric: exactly one of a < b, a == b or a > b is true; and
  • transitive, a < b and b < c implies a < c. The same must hold for both == and >.

Derivable

This trait can be used with #[derive]. When derived, it will produce a lexicographic ordering based on the top-to-bottom declaration order of the struct's members.