Skip to main content

SliceExt

Trait SliceExt 

Source
pub trait SliceExt<T>: Sealed {
    // Required methods
    fn as_hybrid_array<U: ArraySize>(&self) -> Option<&Array<T, U>>;
    fn as_mut_hybrid_array<U: ArraySize>(&mut self) -> Option<&mut Array<T, U>>;
    fn as_hybrid_chunks<U: ArraySize>(&self) -> (&[Array<T, U>], &[T]);
    fn as_hybrid_chunks_mut<U: ArraySize>(
        &mut self,
    ) -> (&mut [Array<T, U>], &mut [T]);
}
Expand description

Extension trait for [T] providing methods for working with Array.

Required Methods§

Source

fn as_hybrid_array<U: ArraySize>(&self) -> Option<&Array<T, U>>

Get a reference to an array from a slice, if the slice is exactly the size of the array.

Returns None if the slice’s length is not exactly equal to the array size.

Source

fn as_mut_hybrid_array<U: ArraySize>(&mut self) -> Option<&mut Array<T, U>>

Get a mutable reference to an array from a slice, if the slice is exactly the size of the array.

Returns None if the slice’s length is not exactly equal to the array size.

Source

fn as_hybrid_chunks<U: ArraySize>(&self) -> (&[Array<T, U>], &[T])

Splits the shared slice into a slice of U-element arrays, starting at the beginning of the slice, and a remainder slice with length strictly less than U.

§Panics

If U is 0.

Source

fn as_hybrid_chunks_mut<U: ArraySize>( &mut self, ) -> (&mut [Array<T, U>], &mut [T])

Splits the exclusive slice into a slice of U-element arrays, starting at the beginning of the slice, and a remainder slice with length strictly less than U.

§Panics

If U is 0.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<T> SliceExt<T> for [T]

Source§

fn as_hybrid_array<U: ArraySize>(&self) -> Option<&Array<T, U>>

Source§

fn as_mut_hybrid_array<U: ArraySize>(&mut self) -> Option<&mut Array<T, U>>

Source§

fn as_hybrid_chunks<U: ArraySize>(&self) -> (&[Array<T, U>], &[T])

Source§

fn as_hybrid_chunks_mut<U: ArraySize>( &mut self, ) -> (&mut [Array<T, U>], &mut [T])

Implementors§