[][src]Function classific::comparing

pub fn comparing<S, T: ?Sized, F>(map: F) -> Comparing<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};

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