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§
Provided Methods§
Sourcefn compares_lt(&self, l: &L, r: &R) -> bool
fn compares_lt(&self, l: &L, r: &R) -> bool
Checks if l is less than r.
Sourcefn compares_le(&self, l: &L, r: &R) -> bool
fn compares_le(&self, l: &L, r: &R) -> bool
Checks if l is less than or equal to r.
Sourcefn compares_ge(&self, l: &L, r: &R) -> bool
fn compares_ge(&self, l: &L, r: &R) -> bool
Checks if l is greater than or equal to r.
Sourcefn compares_gt(&self, l: &L, r: &R) -> bool
fn compares_gt(&self, l: &L, r: &R) -> bool
Checks if l is greater than r.
Sourcefn compares_eq(&self, l: &L, r: &R) -> bool
fn compares_eq(&self, l: &L, r: &R) -> bool
Checks if l is equal to r.
Sourcefn compares_ne(&self, l: &L, r: &R) -> bool
fn compares_ne(&self, l: &L, r: &R) -> bool
Checks if l is not equal to r.