[−][src]Function classific::move_to_cmp_fn
pub fn move_to_cmp_fn<T>(
comparator: impl Comparator<T>
) -> impl Fn(&T, &T) -> Ordering where
T: ?Sized,
This function moves a Comparator
into a Fn(&T, &T) -> Ordering
to make it usable for APIs which doesn't know about Comparator
s.
Examples
use std::cmp::Ordering; use classific::{Comparator, reverse_order, move_to_cmp_fn}; let slice = &mut [1, 2]; slice.sort_by(move_to_cmp_fn(reverse_order())); assert_eq!(slice, &[2, 1]);