[][src]Function classific::comparing_ref_with

pub fn comparing_ref_with<S, T: ?Sized, F, C>(
    map: F,
    cmp: C
) -> ComparingRefWith<S, T, F, C> where
    S: ?Sized,
    T: Ord,
    F: Fn(&S) -> &T,
    C: Comparator<T>, 

This function returns a Comparator for S which first maps values to &T then compare them with cmp.

Examples

use std::cmp::Ordering;
use classific::{Comparator, comparing_ref_with, reverse_order};

assert_eq!(comparing_ref_with(|t: &(i8, i8)| &t.1, reverse_order()).cmp(&(3, 1), &(2, 2)), Ordering::Greater);