pub trait DiffInPlace<T, const N: usize>where
T: PartialEq,{
// Required method
fn try_diff_in_place<F, R>(&self, other: &[T; N], func: F) -> Result<(), R>
where F: FnMut(usize, &[T]) -> Result<(), R>;
// Provided method
fn diff_in_place<F>(&self, other: &[T; N], func: F)
where F: FnMut(usize, &[T]) { ... }
}
Required Methods§
Sourcefn try_diff_in_place<F, R>(&self, other: &[T; N], func: F) -> Result<(), R>
fn try_diff_in_place<F, R>(&self, other: &[T; N], func: F) -> Result<(), R>
Fallible version of diff_in_place
for propagating errors.
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.try_diff_in_place(&b, |idx, diff| -> Result<(), ()> {
// println!("{}: {:?}", idx, diff);
// Prints:
// 2: [1, 2]
// 7: [3, 4, 5]
Ok(())
}).unwrap();
Provided Methods§
Sourcefn diff_in_place<F>(&self, other: &[T; N], func: F)
fn diff_in_place<F>(&self, other: &[T; N], func: F)
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]
});
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.