Skip to main content

OrdContext

Trait OrdContext 

Source
pub trait OrdContext<T> {
    // Required method
    fn less(&self, a: &T, b: &T) -> bool;
}
Expand description

Provides a total ordering for elements of type T.

Implementors replace the standard Ord / PartialOrd traits, enabling context-dependent orderings (e.g. reverse order, key-extracted order) without newtype wrappers.

§Contract

less must define a strict weak ordering:

  • Irreflexivity: less(a, a) is false.
  • Asymmetry: if less(a, b) then !less(b, a).
  • Transitivity: if less(a, b) and less(b, c) then less(a, c).

Required Methods§

Source

fn less(&self, a: &T, b: &T) -> bool

Returns true if a should be ordered before b.

Implementors§