pub fn array_chunks_mut<T, const N: usize>(
vals: &mut [T],
) -> ArrayChunksMut<'_, T, N> ⓘ
Expand description
Returns an iterator over N
elements of the slice at a time, starting at the
beginning of the slice.
The chunks are mutable array references and do not overlap. If N
does not divide
the length of the slice, then the last up to N-1
elements will be omitted and
can be retrieved from the into_remainder
function of the iterator.
This method is the const generic equivalent of chunks_exact_mut
.
§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;
for chunk in array_util::array_chunks_mut(v) {
*chunk = [count; 2];
count += 1;
}
assert_eq!(v, &[1, 1, 2, 2, 0]);