pub fn as_rchunks_mut<T, const N: usize>(
vals: &mut [T],
) -> (&mut [T], &mut [[T; N]])
Expand description
Splits the slice into a slice of N
-element arrays,
starting at the end of the slice,
and a remainder slice with length strictly less than N
.
§Panics
Panics if N
is 0. This check will most probably get changed to a compile time
error before this method gets stabilized.
§Examples
let v = &mut [0, 0, 0, 0, 0];
let mut count = 1;
let (remainder, chunks) = array_util::as_rchunks_mut(v);
remainder[0] = 9;
for chunk in chunks {
*chunk = [count; 2];
count += 1;
}
assert_eq!(v, &[9, 1, 1, 2, 2]);