Skip to main content

array_windows_mut

Function array_windows_mut 

Source
pub fn array_windows_mut<T, const WINDOW_SIZE: usize>(
    slice: &mut [T],
) -> ArrayWindowsMut<'_, T, WINDOW_SIZE>
Expand description

Creates a new lender that returns mutable overlapping array windows of fixed size over a slice.

This is the mutable, lending variant of array_windows. The non-const generic equivalent is windows_mut.

Note that the WindowsMutExt trait provides a convenient entry point for this function as a method on slices and arrays.

See array_windows. for more information.

§Panics

Panics if WINDOW_SIZE is zero.

§Examples

let mut s = [0, 1, 2, 3];
let mut lender = lender::array_windows_mut::<_, 2>(&mut s);
assert_eq!(lender.next(), Some(&mut [0, 1]));

// Using the extension trait
let mut lender = s.array_windows_mut::<2>();
assert_eq!(lender.next(), Some(&mut [0, 1]));