[−][src]Function seqdiff::diff_by
pub fn diff_by<A, B, F>(a: &[A], b: &[B], is_eq: F) -> (Diff, Diff) where
F: Fn(&A, &B) -> bool,
Returns the correspondence between two sequences with a comparison function.
The return value is a pair of tuples. The first tuple contains the index
where the item from the first sequence appears in the 2nd sequence or None
if the item doesn't appear in the 2nd sequence. The 2nd tuple is the same
but listing the corresponding indexes for the 2nd sequence in the first
sequence.
Examples
use seqdiff; let nan_eq = |a: &f64, b: &f64| { if a.is_nan() && b.is_nan() { true } else { a == b } }; let (a2b, b2a) = seqdiff::diff_by(&[1., 2., f64::NAN], &[1., f64::NAN], nan_eq); assert_eq!(a2b, vec![Some(0), None, Some(1)]); assert_eq!(b2a, vec![Some(0), Some(2)]);