pub fn windows_mut<T, const WINDOW_SIZE: usize>(
    slice: &mut [T]
) -> WindowsMut<&mut [T], WINDOW_SIZE>Notable traits for WindowsMut<&'lt mut [T], WINDOW_SIZE>impl<'next, 'lt, T, const WINDOW_SIZE: usize> LendingIteratorඞItem<'next, &'next WindowsMut<&'lt mut [T], WINDOW_SIZE>> for WindowsMut<&'lt mut [T], WINDOW_SIZE> type T = &'next mut [T; WINDOW_SIZE];
Expand description

Creates an impl LendingIterator over the sliding windows of a slice, with &mut / exclusive access over them (yields &mut [T] slices).

This is thus “simply” the mut counter-part of windows(), but for the mut playing a key role w.r.t. semantics and borrows: indeed, the different sliding windows may overlap! This goes against the exclusivity of &mut references, so the different windows cannot coëxist!

This is something that the traditional Iterator trait cannot express, thence this LendingIterator definition which can.

  • This is a free function version of the .windows_mut() method provided by the eponymous extension trait.

    That is, feel free to check out that extension method, since in practice it’s even more ergonomic to use.