Struct Windows

#[must_use = "iterators are lazy and do nothing unless consumed"]
pub struct Windows<'a, T: 'a> { pub(in ::slice::iter) v: &'a [T], pub(in ::slice::iter) size: NonZero<usize> }

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);

Fields

v: &'a [T]
size: NonZero<usize>

Implementations

impl<'a, T: 'a> Windows<'a, T>

const fn new(slice: &'a [T], size: NonZero<usize>) -> Self

Trait Implementations

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

fn next_back(&mut self) -> Option<Self::Item>
fn nth_back(&mut self, n: usize) -> Option<Self::Item>

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

type Item = &'a [T];
fn next(&mut self) -> Option<&'a [T]>
fn size_hint(&self) -> (usize, Option<usize>)
fn count(self) -> usize
fn nth(&mut self, n: usize) -> Option<Self::Item>
fn last(self) -> Option<Self::Item>
unsafe fn __iterator_get_unchecked(&mut self, idx: usize) -> Self::Item

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

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

const MAY_HAVE_SIDE_EFFECT: bool = false;

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

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

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

fn clone(&self) -> Self

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

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

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

Auto Trait Implementations

impl<'a, T> Freeze for Windows<'a, T> where &'a [T]: Freeze,

impl<'a, T> RefUnwindSafe for Windows<'a, T> where &'a [T]: RefUnwindSafe,

impl<'a, T> Send for Windows<'a, T> where &'a [T]: Send,

impl<'a, T> Sync for Windows<'a, T> where &'a [T]: Sync,

impl<'a, T> Unpin for Windows<'a, T> where &'a [T]: Unpin,

impl<'a, T> UnsafeUnpin for Windows<'a, T> where &'a [T]: UnsafeUnpin,

impl<'a, T> UnwindSafe for Windows<'a, T> where &'a [T]: UnwindSafe,

Blanket Implementations

impl<I> IntoIterator for Windows<'a, T> where I: Iterator,

type Item = <I as Iterator>::Item;
type IntoIter = I;
fn into_iter(self) -> I

impl<T> Any for Windows<'a, T> where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for Windows<'a, T> where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for Windows<'a, T> where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> CloneToUninit for Windows<'a, T> where T: Clone,

unsafe fn clone_to_uninit(&self, dest: *mut u8)

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

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> SizeHint for Windows<'a, T> where T: ?Sized,

fn lower_bound(&self) -> usize
fn upper_bound(&self) -> Option<usize>

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

impl<T, U> Into<U> for Windows<'a, T> where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for Windows<'a, T> where U: Into<T>,

type Error = Infallible;
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto<U> for Windows<'a, T> where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>