RecursiveArray

Trait RecursiveArray 

Source
pub unsafe trait RecursiveArray<T>:
    Sized
    + AsRef<[T]>
    + AsMut<[T]> {
    const LENGTH: usize;
    const EMPTY: EmptyRecursiveArray = EmptyRecursiveArray;

    // Provided methods
    fn empty() -> EmptyRecursiveArray { ... }
    fn len(&self) -> usize { ... }
    fn from_array<const N: usize>(array: [T; N]) -> Self { ... }
    fn to_array<const N: usize>(self) -> [T; N] { ... }
    fn from_slice(slice: &[T]) -> &Self { ... }
    fn from_mut_slice(slice: &mut [T]) -> &mut Self { ... }
    fn as_slice(&self) -> &[T] { ... }
    fn as_mut_slice(&mut self) -> &mut [T] { ... }
    fn push_back(
        self,
        item: T,
    ) -> RecursiveArrayConcatenation<T, Self, RecursiveArraySingleItem<T>> { ... }
    fn append_back<R: RecursiveArray<T>>(
        self,
        array: R,
    ) -> RecursiveArrayConcatenation<T, Self, R> { ... }
    fn push_front(
        self,
        item: T,
    ) -> RecursiveArrayConcatenation<T, RecursiveArraySingleItem<T>, Self> { ... }
    fn append_front<R: RecursiveArray<T>>(
        self,
        array: R,
    ) -> RecursiveArrayConcatenation<T, R, Self> { ... }
}
Expand description

a trait which when implemented by some type states that the type’s memory representation can be treated directly as a slice of type T, with a length that is according to the LENGTH constant.

Required Associated Constants§

Source

const LENGTH: usize

the length of this array

Provided Associated Constants§

Source

const EMPTY: EmptyRecursiveArray = EmptyRecursiveArray

an empty recursive array.

Provided Methods§

Source

fn empty() -> EmptyRecursiveArray

returns an empty recursive array.

Source

fn len(&self) -> usize

returns the length of this recursive array.

Source

fn from_array<const N: usize>(array: [T; N]) -> Self

converts the given array to a recursive array.

§Panics

this function panics if the length of the array (N) is not equal to Self::LENGTH. this condition currently can’t be checked at compile time due to the limitation of const generics.

Source

fn to_array<const N: usize>(self) -> [T; N]

converts this recrusive array to a regular array ([T; N]).

§Panics

this function panics if the length of the array (N) is not equal to Self::LENGTH. this condition currently can’t be checked at compile time due to the limitation of const generics.

Source

fn from_slice(slice: &[T]) -> &Self

converts the given slice to a recursive array reference. this is a zero cost operation, which just casts the slice.

§Panics

this function panics if the length of the slice is not equal to Self::LENGTH.

Source

fn from_mut_slice(slice: &mut [T]) -> &mut Self

converts the given mutable slice to a recursive array mutable reference. this is a zero cost operation, which just casts the slice.

§Panics

this function panics if the length of the slice is not equal to Self::LENGTH.

Source

fn as_slice(&self) -> &[T]

returns the elements of this array as a slice.

Source

fn as_mut_slice(&mut self) -> &mut [T]

returns the elements of this array as a mutable slice.

Source

fn push_back( self, item: T, ) -> RecursiveArrayConcatenation<T, Self, RecursiveArraySingleItem<T>>

appends an element to the back of this array.

Source

fn append_back<R: RecursiveArray<T>>( self, array: R, ) -> RecursiveArrayConcatenation<T, Self, R>

appends a recrusive array to the back of this array.

Source

fn push_front( self, item: T, ) -> RecursiveArrayConcatenation<T, RecursiveArraySingleItem<T>, Self>

appends an element to the fron of this array.

Source

fn append_front<R: RecursiveArray<T>>( self, array: R, ) -> RecursiveArrayConcatenation<T, R, Self>

appends a recrusive array to the front of this array.

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.

Implementors§