Skip to main content

Compare

Trait Compare 

Source
pub trait Compare<L: ?Sized, R: ?Sized = L> {
    // Required method
    fn compare(&self, l: &L, r: &R) -> Ordering;

    // Provided methods
    fn compares_lt(&self, l: &L, r: &R) -> bool { ... }
    fn compares_le(&self, l: &L, r: &R) -> bool { ... }
    fn compares_ge(&self, l: &L, r: &R) -> bool { ... }
    fn compares_gt(&self, l: &L, r: &R) -> bool { ... }
    fn compares_eq(&self, l: &L, r: &R) -> bool { ... }
    fn compares_ne(&self, l: &L, r: &R) -> bool { ... }
}
Expand description

A comparator imposing a total order.

The compare method accepts two values (which may be of the same type or different types) and returns an ordering on them.

Comparators are useful for parameterizing the behavior of sort methods and certain data structures like binary heaps.

Required Methods§

Source

fn compare(&self, l: &L, r: &R) -> Ordering

Compares two values, returning Less, Equal, or Greater if l is less than, equal to, or greater than r, respectively.

Provided Methods§

Source

fn compares_lt(&self, l: &L, r: &R) -> bool

Checks if l is less than r.

Source

fn compares_le(&self, l: &L, r: &R) -> bool

Checks if l is less than or equal to r.

Source

fn compares_ge(&self, l: &L, r: &R) -> bool

Checks if l is greater than or equal to r.

Source

fn compares_gt(&self, l: &L, r: &R) -> bool

Checks if l is greater than r.

Source

fn compares_eq(&self, l: &L, r: &R) -> bool

Checks if l is equal to r.

Source

fn compares_ne(&self, l: &L, r: &R) -> bool

Checks if l is not equal to r.

Implementors§

Source§

impl<F, L: ?Sized, R: ?Sized> Compare<L, R> for F
where F: Fn(&L, &R) -> Ordering,

Blanket implementation for closures.

Source§

impl<I> Compare<ElementBatchIter<I, Data>> for TsInitComparator
where I: Iterator<Item = IntoIter<Data>>,