[][src]Function classific::comparing_ref

pub fn comparing_ref<S, T: ?Sized, F>(map: F) -> ComparingRef<S, T, F> where
    S: ?Sized,
    T: Ord,
    F: Fn(&S) -> &T, 

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

Examples

use std::cmp::Ordering;
use classific::{Comparator, comparing_ref};

assert_eq!(comparing_ref(|t: &(i8, i8)| &t.1).cmp(&(3, 1), &(2, 2)), Ordering::Less);