Trait diff_in_place::DiffInPlace
source · pub trait DiffInPlace<T, const N: usize>where
T: PartialEq,{
// Required method
fn diff_in_place<F>(&self, other: &[T; N], func: F)
where F: FnMut(usize, &[T]);
}
Required Methods§
sourcefn diff_in_place<F>(&self, other: &[T; N], func: F)where
F: FnMut(usize, &[T]),
fn diff_in_place<F>(&self, other: &[T; N], func: F)where F: FnMut(usize, &[T]),
Perform an in-place diff between two const-size arrays, invoking the given function for each run of different elements, with the index into the array and the slice of different elements from the other array.
Arguments
other
- The other array to compare against.func
- The function to call for each run of different elements.
Example
use diff_in_place::DiffInPlace;
let a = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
let mut b = [0, 0, 1, 2, 0, 0, 0, 3, 4, 5];
a.diff_in_place(&b, |idx, diff| {
// println!("{}: {:?}", idx, diff);
// Prints:
// 2: [1, 2]
// 7: [3, 4, 5]
});
Object Safety§
This trait is not object safe.