Struct ArrayWindows

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

A windowed iterator over a slice in overlapping chunks (N elements at a time), starting at the beginning of the slice

This struct is created by the array_windows method on slices.

Example

let slice = [0, 1, 2, 3];
let mut iter = slice.array_windows::<2>();
assert_eq!(iter.next(), Some(&[0, 1]));
assert_eq!(iter.next(), Some(&[1, 2]));
assert_eq!(iter.next(), Some(&[2, 3]));
assert_eq!(iter.next(), None);

Fields

v: &'a [T]

Implementations

impl<'a, T: 'a, const N: usize> ArrayWindows<'a, T, N>

const fn new(slice: &'a [T]) -> Self

Trait Implementations

impl<'a, T, const N: usize> DoubleEndedIterator for ArrayWindows<'a, T, N>

fn next_back(&mut self) -> Option<&'a [T; N]>
fn nth_back(&mut self, n: usize) -> Option<&'a [T; N]>

impl<'a, T, const N: usize> Iterator for ArrayWindows<'a, T, N>

type Item = &'a [T; N];
fn next(&mut self) -> Option<Self::Item>
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: Debug + 'a, const N: usize> Debug for ArrayWindows<'a, T, N>

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

impl<T, const N: usize> Clone for ArrayWindows<'_, T, N>

fn clone(&self) -> Self

impl<T, const N: usize> ExactSizeIterator for ArrayWindows<'_, T, N>

fn is_empty(&self) -> bool

impl<T, const N: usize> FusedIterator for ArrayWindows<'_, T, N>

impl<T, const N: usize> TrustedLen for ArrayWindows<'_, T, N>

impl<T, const N: usize> TrustedRandomAccess for ArrayWindows<'_, T, N>

impl<T, const N: usize> TrustedRandomAccessNoCoerce for ArrayWindows<'_, T, N>

const MAY_HAVE_SIDE_EFFECT: bool = false;

Auto Trait Implementations

impl<'a, T, const N: usize> Freeze for ArrayWindows<'a, T, N> where &'a [T]: Freeze,

impl<'a, T, const N: usize> RefUnwindSafe for ArrayWindows<'a, T, N> where &'a [T]: RefUnwindSafe,

impl<'a, T, const N: usize> Send for ArrayWindows<'a, T, N> where &'a [T]: Send,

impl<'a, T, const N: usize> Sync for ArrayWindows<'a, T, N> where &'a [T]: Sync,

impl<'a, T, const N: usize> Unpin for ArrayWindows<'a, T, N> where &'a [T]: Unpin,

impl<'a, T, const N: usize> UnsafeUnpin for ArrayWindows<'a, T, N> where &'a [T]: UnsafeUnpin,

impl<'a, T, const N: usize> UnwindSafe for ArrayWindows<'a, T, N> where &'a [T]: UnwindSafe,

Blanket Implementations

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

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

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

fn type_id(&self) -> TypeId

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

fn borrow(&self) -> &T

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

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

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

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

impl<T> From<T> for ArrayWindows<'a, T, N>

fn from(t: T) -> T

Returns the argument unchanged.

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

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

impl<T> SizedTypeProperties for ArrayWindows<'a, T, N>

impl<T, U> Into<U> for ArrayWindows<'a, T, N> 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 ArrayWindows<'a, T, N> 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 ArrayWindows<'a, T, N> where U: TryFrom<T>,

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