Struct RChunksExactMut

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

An iterator over a slice in (non-overlapping) mutable 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 up to chunk_size-1 elements will be omitted but can be retrieved from the into_remainder function from the iterator.

This struct is created by the rchunks_exact_mut method on slices.

Example

let mut slice = ['l', 'o', 'r', 'e', 'm'];
let iter = slice.rchunks_exact_mut(2);

Fields

v: *mut [T]

Safety

This slice pointer must point at a valid region of T with at least length v.len(). Normally, those requirements would mean that we could instead use a &mut [T] here, but we cannot because __iterator_get_unchecked needs to return &mut [T], which guarantees certain aliasing properties that we cannot uphold if we hold on to the full original &mut [T]. Wrapping a raw slice instead lets us hand out non-overlapping &mut [T] subslices of the slice we wrap.

rem: &'a mut [T]
chunk_size: usize

Implementations

impl<'a, T> RChunksExactMut<'a, T>

const fn new(slice: &'a mut [T], chunk_size: usize) -> Self
const fn into_remainder(self) -> &'a mut [T]

Returns the remainder of the original slice that is not going to be returned by the iterator. The returned slice has at most chunk_size-1 elements.

Trait Implementations

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

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

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

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

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

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

const MAY_HAVE_SIDE_EFFECT: bool = false;

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

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

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

fn is_empty(&self) -> bool

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

impl<T> Send for RChunksExactMut<'_, T> where T: Send,

impl<T> Sync for RChunksExactMut<'_, T> where T: Sync,

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

Auto Trait Implementations

impl<'a, T> !UnwindSafe for RChunksExactMut<'a, T>

impl<'a, T> Freeze for RChunksExactMut<'a, T> where *mut [T]: Freeze, &'a mut [T]: Freeze,

impl<'a, T> RefUnwindSafe for RChunksExactMut<'a, T> where *mut [T]: RefUnwindSafe, &'a mut [T]: RefUnwindSafe,

impl<'a, T> Unpin for RChunksExactMut<'a, T> where *mut [T]: Unpin, &'a mut [T]: Unpin,

impl<'a, T> UnsafeUnpin for RChunksExactMut<'a, T> where *mut [T]: UnsafeUnpin, &'a mut [T]: UnsafeUnpin,

Blanket Implementations

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

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

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

fn type_id(&self) -> TypeId

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

fn borrow(&self) -> &T

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

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

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

fn from(t: T) -> T

Returns the argument unchanged.

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

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

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

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

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