Struct ChunksExact
#[must_use = "iterators are lazy and do nothing unless consumed"]
pub struct ChunksExact<'a, T: 'a> { pub(in ::slice::iter) v: &'a [T], pub(in ::slice::iter) rem: &'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 beginning 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 remainder function from the iterator.
This struct is created by the chunks_exact method on slices.
Example
let slice = ;
let mut iter = slice.chunks_exact;
assert_eq!;
assert_eq!;
assert_eq!;
Fields
v: &'a [T]rem: &'a [T]chunk_size: usize
Implementations
impl<'a, T> ChunksExact<'a, T>
const fn new(slice: &'a [T], chunk_size: usize) -> Selffn remainder(&self) -> &'a [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-1elements.Example
let slice = ; let mut iter = slice.chunks_exact; assert_eq!; assert_eq!; assert_eq!; assert_eq!; assert_eq!; assert_eq!; assert_eq!;
Trait Implementations
impl<'a, T> DoubleEndedIterator for ChunksExact<'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 ChunksExact<'a, T>
type Item = &'a [T];fn next(&mut self) -> Option<&'a [T]>fn size_hint(&self) -> (usize, Option<usize>)fn count(self) -> usizefn 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 ChunksExact<'a, T>
impl<'a, T> TrustedRandomAccessNoCoerce for ChunksExact<'a, T>
const MAY_HAVE_SIDE_EFFECT: bool = false;
impl<'a, T: Debug + 'a> Debug for ChunksExact<'a, T>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl<T> Clone for ChunksExact<'_, T>
fn clone(&self) -> Self
impl<T> ExactSizeIterator for ChunksExact<'_, T>
fn is_empty(&self) -> bool
impl<T> FusedIterator for ChunksExact<'_, T>
impl<T> TrustedLen for ChunksExact<'_, T>
Auto Trait Implementations
impl<'a, T> Freeze for ChunksExact<'a, T>
where
&'a [T]: Freeze + Freeze,
impl<'a, T> RefUnwindSafe for ChunksExact<'a, T>
where
&'a [T]: RefUnwindSafe + RefUnwindSafe,
impl<'a, T> Send for ChunksExact<'a, T>
where
&'a [T]: Send + Send,
impl<'a, T> Sync for ChunksExact<'a, T>
where
&'a [T]: Sync + Sync,
impl<'a, T> Unpin for ChunksExact<'a, T>
where
&'a [T]: Unpin + Unpin,
impl<'a, T> UnsafeUnpin for ChunksExact<'a, T>
where
&'a [T]: UnsafeUnpin + UnsafeUnpin,
impl<'a, T> UnwindSafe for ChunksExact<'a, T>
where
&'a [T]: UnwindSafe + UnwindSafe,
Blanket Implementations
impl<I> IntoIterator for ChunksExact<'a, T>
where
I: Iterator,
type Item = <I as Iterator>::Item;type IntoIter = I;fn into_iter(self) -> I
impl<T> Any for ChunksExact<'a, T>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for ChunksExact<'a, T>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for ChunksExact<'a, T>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for ChunksExact<'a, T>
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for ChunksExact<'a, T>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> SizeHint for ChunksExact<'a, T>
where
T: ?Sized,
fn lower_bound(&self) -> usizefn upper_bound(&self) -> Option<usize>
impl<T> SizedTypeProperties for ChunksExact<'a, T>
impl<T, U> Into<U> for ChunksExact<'a, T>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for ChunksExact<'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 ChunksExact<'a, T>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>