Skip to main content

Windows

Struct Windows 

1.0.0 · Source
pub struct Windows<'a, T>
where T: 'a,
{ /* private fields */ }
Expand description

An iterator over overlapping subslices of length size.

This struct is created by the windows method on slices.

§Example

let slice = ['r', 'u', 's', 't'];
let mut iter = slice.windows(2);
assert_eq!(iter.next(), Some(&['r', 'u'][..]));
assert_eq!(iter.next(), Some(&['u', 's'][..]));
assert_eq!(iter.next(), Some(&['s', 't'][..]));
assert_eq!(iter.next(), None);

Trait Implementations§

1.0.0 · Source§

impl<T> Clone for Windows<'_, T>

Source§

fn clone(&self) -> Windows<'_, T> ⓘ

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
1.0.0 · Source§

impl<'a, T> Debug for Windows<'a, T>
where T: Debug + 'a,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
1.0.0 · Source§

impl<'a, T> DoubleEndedIterator for Windows<'a, T>

Source§

fn next_back(&mut self) -> Option<<Windows<'a, T> as Iterator>::Item>

Removes and returns an element from the end of the iterator. Read more
Source§

fn nth_back(&mut self, n: usize) -> Option<<Windows<'a, T> as Iterator>::Item>

Returns the nth element from the end of the iterator. Read more
Source§

fn next_chunk_back<const N: usize>( &mut self, ) -> Result<[Self::Item; N], IntoIter<Self::Item, N>>
where Self: Sized,

🔬This is a nightly-only experimental API. (iter_next_chunk #98326)
Advances from the back of the iterator and returns an array containing the next N values in sequence. Read more
Source§

fn advance_back_by(&mut self, n: usize) -> Result<(), NonZero<usize>>

🔬This is a nightly-only experimental API. (iter_advance_by #77404)
Advances the iterator from the back by n elements. Read more
1.27.0 (const: unstable) · Source§

fn try_rfold<B, F, R>(&mut self, init: B, f: F) -> R
where Self: Sized, F: FnMut(B, Self::Item) -> R, R: Try<Output = B>,

This is the reverse version of Iterator::try_fold(): it takes elements starting from the back of the iterator. Read more
1.27.0 (const: unstable) · Source§

fn rfold<B, F>(self, init: B, f: F) -> B
where Self: Sized, F: FnMut(B, Self::Item) -> B,

An iterator method that reduces the iterator’s elements to a single, final value, starting from the back. Read more
1.27.0 (const: unstable) · Source§

fn rfind<P>(&mut self, predicate: P) -> Option<Self::Item>
where Self: Sized, P: FnMut(&Self::Item) -> bool,

Searches for an element of an iterator from the back that satisfies a predicate. Read more
1.0.0 ·