Function as_chunks_mut

Source
pub fn as_chunks_mut<T, const N: usize>(
    vals: &mut [T],
) -> (&mut [[T; N]], &mut [T])
Expand description

Splits the slice into a slice of N-element arrays, starting at the beginning 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 (chunks, remainder) = array_util::as_chunks_mut(v);
remainder[0] = 9;
for chunk in chunks {
    *chunk = [count; 2];
    count += 1;
}
assert_eq!(v, &[1, 1, 2, 2, 9]);