Struct compare::Extract
[−]
[src]
pub struct Extract<E, C> {
// some fields omitted
}A comparator that extracts a sort key from a value.
Examples
use compare::{Compare, Extract}; use std::cmp::Ordering::Greater; let a = [1, 2, 3]; let b = [4, 5]; let cmp = Extract::new(|s: &[i32]| s.len()); assert_eq!(cmp.compare(&a, &b), Greater);
Methods
impl<E, K> Extract<E, Natural<K>> where K: Ord
fn new<T: ?Sized>(ext: E) -> Self where E: Fn(&T) -> K
Returns a comparator that extracts a sort key using ext and compares it according to its
natural ordering.
impl<E, C> Extract<E, C>
fn with_cmp<T: ?Sized, K>(ext: E, cmp: C) -> Self where E: Fn(&T) -> K, C: Compare<K>
Returns a comparator that extracts a sort key using ext and compares it using
cmp.