Struct slice_utils::Cycle

source ·
pub struct Cycle<T, A>(pub A, _);
Expand description

An infinitely looped slice, from Slice::cycle.

Tuple Fields§

§0: A

Implementations§

source§

impl<T, A> Cycle<T, A>
where A: Slice<T>,

source

pub fn new(data: A) -> Self

source§

impl<T, A> Cycle<T, A>
where A: Slice<T>,

source

pub fn iter(&self) -> Iter<'_, T, Self>

Trait Implementations§

source§

impl<T: Clone, A: Clone> Clone for Cycle<T, A>

source§

fn clone(&self) -> Cycle<T, A>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T, A> Debug for Cycle<T, A>
where T: Debug, A: Slice<T>,

source§

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

Formats the value using the given formatter. Read more
source§

impl<T: Hash, A: Hash> Hash for Cycle<T, A>

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<T, A> Index<usize> for Cycle<T, A>
where A: Slice<T>,

§

type Output = T

The returned type after indexing.
source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
source§

impl<T, A> IndexMut<usize> for Cycle<T, A>
where Cycle<T, A>: SliceMut<T>, A: SliceMut<T>,

source§

fn index_mut(&mut self, index: usize) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
source§

impl<'a, T, A> IntoIterator for &'a Cycle<T, A>
where A: Slice<T>,

§

type Item = &'a T

The type of the elements being iterated over.
§

type IntoIter = Iter<'a, T, Cycle<T, A>>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<'a, T, A> PartialEq<&'a [T]> for Cycle<T, A>
where T: PartialEq, A: Slice<T>,

source§

fn eq(&self, other: &&'a [T]) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T, A> PartialEq<[T]> for Cycle<T, A>
where T: PartialEq, A: Slice<T>,

source§

fn eq(&self, other: &[T]) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T, A, const N: usize> PartialEq<[T; N]> for Cycle<T, A>
where T: PartialEq, A: Slice<T>,

source§

fn eq(&self, other: &[T; N]) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T: PartialEq, A: PartialEq> PartialEq for Cycle<T, A>

source§

fn eq(&self, other: &Cycle<T, A>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T, A> Slice<T> for Cycle<T, A>
where A: Slice<T>,

source§

fn get(&self, index: usize) -> Option<&T>

Index the slice. Read more
source§

fn len(&self) -> usize

Returns the exact length of the slice. Read more
source§

fn is_empty(&self) -> bool

Whether or not the slice is empty (self.len() == 0). Read more
source§

fn slice<R: RangeBounds<usize>>(self, range: R) -> Option<SliceOf<T, Self>>

Takes a sub-slice, returning None if the range is out-of-bounds. Read more
source§

fn skip(self, n: usize) -> Option<SliceOf<T, Self>>

source§

fn take(self, n: usize) -> Option<SliceOf<T, Self>>

Shorcut for .slice(..=n). Read more
source§

fn chain<O: Slice<T>>(self, other: O) -> Chain<T, Self, O>

Chains two slices together, back-to-back: the equivalent of Iterator::chain. Read more
source§

fn cycle(self) -> Cycle<T, Self>

Repeats the slice forever: the equivalent of Iterator::cycle. Read more
source§

fn interleave<O: Slice<T>>(self, other: O) -> Interleave<T, Self, O>

Interleaves two slices, e.g. [A, B, A, B, …]. Read more
source§

fn reverse(self) -> Reverse<T, Self>

Reverses the slice: the equivalent of Iterator::rev. Read more
source§

fn windows(&self, size: usize) -> Windows<'_, T, Self>

Returns an iterator over overlapping slices of length size: the equivalent of slice::windows. Read more
source§

fn split(&self, at: usize) -> Option<SplitOf<T, &Self>>

Returns (&self[..at], &self[at..]). Returns None if at is out-of-bounds. Read more
source§

impl<T, A> SliceMut<T> for Cycle<T, A>
where A: SliceMut<T>,

source§

fn get_mut(&mut self, index: usize) -> Option<&mut T>

Mutably index the slice. Read more
source§

fn slice_mut<R: RangeBounds<usize>>( self, range: R ) -> Option<SliceOfMut<T, Self>>

Takes a mutable sub-slice, returning None if the range is out-of-bounds. Read more
source§

fn map<F>(&mut self, f: F)
where F: for<'a> FnMut(&mut T),

Calls a closure on each item, mutating it. Read more
source§

impl<T: Copy, A: Copy> Copy for Cycle<T, A>

source§

impl<T: Eq, A: Eq> Eq for Cycle<T, A>

source§

impl<T, A> StructuralPartialEq for Cycle<T, A>

Auto Trait Implementations§

§

impl<T, A> Freeze for Cycle<T, A>
where A: Freeze,

§

impl<T, A> RefUnwindSafe for Cycle<T, A>
where A: RefUnwindSafe,

§

impl<T, A> Send for Cycle<T, A>
where A: Send,

§

impl<T, A> Sync for Cycle<T, A>
where A: Sync,

§

impl<T, A> Unpin for Cycle<T, A>
where A: Unpin,

§

impl<T, A> UnwindSafe for Cycle<T, A>
where A: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

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

Performs the conversion.