[−][src]Function classific::comparing_with
pub fn comparing_with<S, T: ?Sized, F, C>(
map: F,
cmp: C
) -> ComparingWith<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_with, reverse_order}; assert_eq!(comparing_with(|t: &(i8, i8)| t.1, reverse_order()).cmp(&(3, 1), &(2, 2)), Ordering::Greater);