[−][src]Function classific::move_to_eq_fn
pub fn move_to_eq_fn<T>(eq_class: impl EqClass<T>) -> impl Fn(&T, &T) -> bool where
T: ?Sized,
This function moves an EqClass
into a Fn(&T, &T) -> bool
to make it usable for APIs which doesn't know about EqClass
es.
Examples
use classific::{EqClass, eq_by, move_to_eq_fn}; let mut iter = [(1, 1), (2, 1), (3, 1)].iter(); let first = iter.next(); let eq = move_to_eq_fn(eq_by(|i: &(i8, i8)| i.1)); let r = iter.fold(first, move |acc, next| match acc { Some(a) => if eq(a, next) { Some(next) } else { None }, none => none, }); assert!(r.is_some());