Struct compare::Extract [] [src]

pub struct Extract<E, C> { /* 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
[src]

Returns a comparator that extracts a sort key using ext and compares it according to its natural ordering.

impl<E, C> Extract<E, C>
[src]

Returns a comparator that extracts a sort key using ext and compares it using cmp.

Trait Implementations

impl<E: Clone, C: Clone> Clone for Extract<E, C>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<E: Copy, C: Copy> Copy for Extract<E, C>
[src]

impl<E: Debug, C: Debug> Debug for Extract<E, C>
[src]

Formats the value using the given formatter.

impl<E: Default, C: Default> Default for Extract<E, C>
[src]

Returns the "default value" for a type. Read more

impl<E: PartialEq, C: PartialEq> PartialEq for Extract<E, C>
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl<E: Eq, C: Eq> Eq for Extract<E, C>
[src]

impl<E, C, T: ?Sized, K> Compare<T> for Extract<E, C> where
    E: Fn(&T) -> K,
    C: Compare<K>, 
[src]

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

Checks if l is less than r.

Checks if l is less than or equal to r.

Checks if l is greater than or equal to r.

Checks if l is greater than r.

Checks if l is equal to r.

Checks if l is not equal to r.

Borrows the comparator's parameters before comparing them. Read more

Reverses the ordering of the comparator. Read more

Swaps the comparator's parameters, maintaining the underlying ordering. Read more

Lexicographically combines the comparator with another. Read more