Skip to main content

windows_mut

Function windows_mut 

Source
pub fn windows_mut<T>(slice: &mut [T], size: usize) -> WindowsMut<'_, T>
Expand description

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

This is the mutable, lending variant of windows. The const generic equivalent is array_windows_mut.

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

§Panics

Panics if size is zero.

§Examples

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

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