Struct slice_utils::Interleave

source ·
pub struct Interleave<T, A, B> {
    pub left: A,
    pub right: B,
    /* private fields */
}
Expand description

Two interleaved slices, from Slice::interleave.

Fields§

§left: A§right: B

Implementations§

source§

impl<T, A, B> Interleave<T, A, B>
where A: Slice<T>, B: Slice<T>,

source

pub fn new(left: A, right: B) -> Self

Trait Implementations§

source§

impl<T, A, B> Debug for Interleave<T, A, B>
where T: Debug, A: Slice<T>, B: Slice<T>,

source§

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

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

impl<T, A, B> Index<usize> for Interleave<T, A, B>
where A: Slice<T>, B: 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, B> IndexMut<usize> for Interleave<T, A, B>
where Interleave<T, A, B>: SliceMut<T>, A: SliceMut<T>, B: 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, B> PartialEq<&'a [T]> for Interleave<T, A, B>
where T: PartialEq, A: Slice<T>, B: 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, B> PartialEq<[T]> for Interleave<T, A, B>
where T: PartialEq, A: Slice<T>, B: 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, B, const N: usize> PartialEq<[T; N]> for Interleave<T, A, B>
where T: PartialEq, A: Slice<T>, B: 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, A, B> Slice<T> for Interleave<T, A, B>
where A: Slice<T>, B: 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, B> SliceMut<T> for Interleave<T, A, B>
where A: SliceMut<T>, B: 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

Auto Trait Implementations§

§

impl<T, A, B> Freeze for Interleave<T, A, B>
where A: Freeze, B: Freeze,

§

impl<T, A, B> RefUnwindSafe for Interleave<T, A, B>

§

impl<T, A, B> Send for Interleave<T, A, B>
where A: Send, B: Send,

§

impl<T, A, B> Sync for Interleave<T, A, B>
where A: Sync, B: Sync,

§

impl<T, A, B> Unpin for Interleave<T, A, B>
where A: Unpin, B: Unpin,

§

impl<T, A, B> UnwindSafe for Interleave<T, A, B>
where A: UnwindSafe, B: 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.