Struct RChunks

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

An iterator over a slice in (non-overlapping) chunks (chunk_size elements at a time), starting at the end of the slice.

When the slice len is not evenly divided by the chunk size, the last slice of the iteration will be the remainder.

This struct is created by the rchunks method on slices.

Example

let slice = ['l', 'o', 'r', 'e', 'm'];
let mut iter = slice.rchunks(2);
assert_eq!(iter.next(), Some(&['e', 'm'][..]));
assert_eq!(iter.next(), Some(&['o', 'r'][..]));
assert_eq!(iter.next(), Some(&['l'][..]));
assert_eq!(iter.next(), None);

Fields

v: &'a [T]
chunk_size: usize

Implementations

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

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

Trait Implementations

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

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

impl<'a, T> Iterator for RChunks<'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 RChunks<'a, T>

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

const MAY_HAVE_SIDE_EFFECT: bool = false;

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

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

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

fn clone(&self) -> Self

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

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

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

Auto Trait Implementations

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

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

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

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

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

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

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

Blanket Implementations

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

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

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

fn type_id(&self) -> TypeId

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

fn borrow(&self) -> &T

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

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

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

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

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

fn from(t: T) -> T

Returns the argument unchanged.

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

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

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

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

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