pub struct ChunkStridedSliceRef<T, const N: usize>(/* private fields */);Expand description
Non-owning strided view over N interleaved lanes in a flat buffer.
ChunkStridedSliceRef<T, N> presents N parallel lanes of T values that step
through memory with a common stride. It is the N-lane analogue of
StridedSliceRef: element (i, j) lives at base + i * stride + offsets[j].
This type is #[repr(transparent)] over its internal ChunkStrideParts, so it
can be safely constructed via pointer casts inside ChunkStridedSliceBase.
Implementations§
Source§impl<T, const N: usize> ChunkStridedSliceRef<T, N>
impl<T, const N: usize> ChunkStridedSliceRef<T, N>
Sourcepub fn as_mut_ptr(&mut self) -> *mut T
pub fn as_mut_ptr(&mut self) -> *mut T
Return a mut pointer to the base element of this view.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Number of positions (rows) in the view. Each position holds N elements.
Sourcepub fn get(&self, (i0, i1): (usize, usize)) -> Option<&T>
pub fn get(&self, (i0, i1): (usize, usize)) -> Option<&T>
Return a reference to element (i0, i1), or None if either index is out of bounds.
Sourcepub unsafe fn get_unchecked(&self, (i0, i1): (usize, usize)) -> &T
pub unsafe fn get_unchecked(&self, (i0, i1): (usize, usize)) -> &T
Return a reference to element (i0, i1) without bounds checking.
§Safety
i0 < self.len() and i1 < N must both hold.
Sourcepub fn get_mut(&mut self, (i0, i1): (usize, usize)) -> Option<&mut T>
pub fn get_mut(&mut self, (i0, i1): (usize, usize)) -> Option<&mut T>
Return a mutable reference to element (i0, i1), or None if either index is out of bounds.
Sourcepub unsafe fn get_unchecked_mut(&mut self, (i0, i1): (usize, usize)) -> &mut T
pub unsafe fn get_unchecked_mut(&mut self, (i0, i1): (usize, usize)) -> &mut T
Return a mutable reference to element (i0, i1) without bounds checking.
§Safety
i0 < self.len() and i1 < N must both hold.
Sourcepub fn is_chunk_contiguous(&self) -> bool
pub fn is_chunk_contiguous(&self) -> bool
Return true if the N elements at each position are stored at consecutive addresses.
Sourcepub fn is_contiguous(&self) -> bool
pub fn is_contiguous(&self) -> bool
Return true if both the inter-position stride equals N and the chunk is contiguous,
meaning the entire view is a flat &[[T; N]].
Sourcepub fn as_slice(&self) -> Option<&[T]>
pub fn as_slice(&self) -> Option<&[T]>
Return the chunks’s data as a slice, if it represents a contiguous region of memory. Return None otherwise.
Sourcepub fn as_slices(&self) -> Option<[&[T]; N]>
pub fn as_slices(&self) -> Option<[&[T]; N]>
Return the chunks’s data as an array of slices, if each slice represents a contiguous region of memory. Return None otherwise.
Sourcepub fn as_mut_slices(&mut self) -> Option<[&mut [T]; N]>
pub fn as_mut_slices(&mut self) -> Option<[&mut [T]; N]>
Return the mutable chunks’s data as an array of mutable slices, if each slice represents a contiguous region of memory. Return None otherwise.
Sourcepub fn as_mut_slice(&mut self) -> Option<&mut [T]>
pub fn as_mut_slice(&mut self) -> Option<&mut [T]>
Return the mutable chunks’s data as a mutable slice, if it represents a contiguous region of memory. Return None otherwise.
Sourcepub fn as_chunks(&self) -> Option<&[[T; N]]>
pub fn as_chunks(&self) -> Option<&[[T; N]]>
Return the chunks’s data as a slice of arrays, if it represents a contiguous region of memory. Return None otherwise.
Sourcepub fn as_mut_chunks(&mut self) -> Option<&mut [[T; N]]>
pub fn as_mut_chunks(&mut self) -> Option<&mut [[T; N]]>
Return the mutable chunks’s data as a mutable slice or arrays, if it represents a contiguous region of memory. Return None otherwise.
Sourcepub fn iter(&self) -> Iter<'_, T, N> ⓘ
pub fn iter(&self) -> Iter<'_, T, N> ⓘ
Return an iterator that yields N-element arrays at each position.
Sourcepub fn try_array_chunks(&self) -> Result<ArrayChunks<'_, T, N>, &'static str>
pub fn try_array_chunks(&self) -> Result<ArrayChunks<'_, T, N>, &'static str>
Return an iterator over &[T; N] slices if the N elements at each position are contiguous,
or an error if they are not.
Sourcepub fn iter_mut(&mut self) -> IterMut<'_, T, N> ⓘ
pub fn iter_mut(&mut self) -> IterMut<'_, T, N> ⓘ
Return a mutable iterator that yields N-element arrays at each position.
Sourcepub fn try_array_chunks_mut(
&mut self,
) -> Result<ArrayChunksMut<'_, T, N>, &'static str>
pub fn try_array_chunks_mut( &mut self, ) -> Result<ArrayChunksMut<'_, T, N>, &'static str>
Return a mutable iterator over &mut [T; N] slices if the N elements at each position are
contiguous, or an error if they are not.
Source§impl<T: Clone, const N: usize> ChunkStridedSliceRef<T, N>
impl<T: Clone, const N: usize> ChunkStridedSliceRef<T, N>
Sourcepub fn deinterleave<V>(&self, evens: &mut [V; N], odds: &mut [V; N])
pub fn deinterleave<V>(&self, evens: &mut [V; N], odds: &mut [V; N])
Deinterleave N strided slices into N slices
self presents N interleaved lanes; evens[j] and odds[j] receive the even- and
odd-indexed elements of lane j, respectively.
§Panics
Panics if any evens[j].len() != (self.len() + 1) / 2 or odds[j].len() != self.len() / 2.
Sourcepub fn deinterleave_arrays(&self, evens: &mut [[T; N]], odds: &mut [[T; N]])
pub fn deinterleave_arrays(&self, evens: &mut [[T; N]], odds: &mut [[T; N]])
Deinterleave into a slice of arrays.
§Panics
Panics if evens.len() != (self.len() + 1) / 2 or odds.len() != self.len() / 2.
Sourcepub fn interleave<V>(&mut self, evens: &[V; N], odds: &[V; N])
pub fn interleave<V>(&mut self, evens: &[V; N], odds: &[V; N])
N slices are interleaved into N strided slices.
self presents N lanes; evens[j] and odds[j] are the source of the even- and
odd-indexed elements of lane j, respectively.
§Panics
Panics if any evens[j].len() != (self.len() + 1) / 2 or odds[j].len() != self.len() / 2.
Sourcepub fn interleave_arrays(&mut self, evens: &[[T; N]], odds: &[[T; N]])
pub fn interleave_arrays(&mut self, evens: &[[T; N]], odds: &[[T; N]])
N slices are interleaved into N strided slices.
§Panics
Panics if evens.len() != (self.len() + 1) / 2 or odds.len() != self.len() / 2.
Sourcepub fn split<V>(&self, first: &mut [V; N], second: &mut [V; N])
pub fn split<V>(&self, first: &mut [V; N], second: &mut [V; N])
Chunk-strided variant of StridedSliceRef::split: read N lanes from a ChunkStridedSliceRef.
Fills first and second with the head and tail ends, respectively, of the N strided lanes.
§Panics
Panics if first[0].len() + second[0].len() > self.len(), or if not all slices in first
have the same length, or if not all slices in second have the same length.
Sourcepub fn split_arrays(&self, first: &mut [[T; N]], second: &mut [[T; N]])
pub fn split_arrays(&self, first: &mut [[T; N]], second: &mut [[T; N]])
Chunk-strided variant of StridedSliceRef::split: read N interleaved lanes from a ChunkStridedSliceRef.
§Panics
Panics if first.len() + second.len() > self.len().
Source§impl<T: Clone + Zero, const N: usize> ChunkStridedSliceRef<T, N>
impl<T: Clone + Zero, const N: usize> ChunkStridedSliceRef<T, N>
Sourcepub fn stack<V>(&mut self, first: &[V; N], second: &[V; N])
pub fn stack<V>(&mut self, first: &[V; N], second: &[V; N])
Stack N slices into N strided slices
This is the chunked version of StridedSliceRef::stack
§Panics
Panics if first[0].len() + second[0].len() > self.len(), or if not all slices in first
have the same length, or if not all slices in second have the same length.
Sourcepub fn stack_arrays(&mut self, first: &[[T; N]], second: &[[T; N]])
pub fn stack_arrays(&mut self, first: &[[T; N]], second: &[[T; N]])
Stack arrays of N elements into the strided slice.
§Panics
Panics if first.len() + second.len() > self.len().
Trait Implementations§
impl<T: Send, const N: usize> Send for ChunkStridedSliceRef<T, N>
impl<T: Sync, const N: usize> Sync for ChunkStridedSliceRef<T, N>
Auto Trait Implementations§
impl<T, const N: usize> Freeze for ChunkStridedSliceRef<T, N>
impl<T, const N: usize> RefUnwindSafe for ChunkStridedSliceRef<T, N>where
T: RefUnwindSafe,
impl<T, const N: usize> Unpin for ChunkStridedSliceRef<T, N>
impl<T, const N: usize> UnsafeUnpin for ChunkStridedSliceRef<T, N>
impl<T, const N: usize> UnwindSafe for ChunkStridedSliceRef<T, N>where
T: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more