Trait recursive_array::RecursiveArray
source · pub unsafe trait RecursiveArray<T>: Sized {
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§
Provided Associated Constants§
sourceconst EMPTY: EmptyRecursiveArray = EmptyRecursiveArray
const EMPTY: EmptyRecursiveArray = EmptyRecursiveArray
an empty recursive array.
Provided Methods§
sourcefn empty() -> EmptyRecursiveArray
fn empty() -> EmptyRecursiveArray
returns an empty recursive array.
sourcefn from_array<const N: usize>(array: [T; N]) -> Self
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.
sourcefn to_array<const N: usize>(self) -> [T; N]
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.
sourcefn from_slice(slice: &[T]) -> &Self
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.
sourcefn from_mut_slice(slice: &mut [T]) -> &mut Self
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.
sourcefn as_mut_slice(&mut self) -> &mut [T]
fn as_mut_slice(&mut self) -> &mut [T]
returns the elements of this array as a mutable slice.
sourcefn push_back(
self,
item: T
) -> RecursiveArrayConcatenation<T, Self, RecursiveArraySingleItem<T>>
fn push_back( self, item: T ) -> RecursiveArrayConcatenation<T, Self, RecursiveArraySingleItem<T>>
appends an element to the back of this array.
sourcefn append_back<R: RecursiveArray<T>>(
self,
array: R
) -> RecursiveArrayConcatenation<T, Self, R>
fn append_back<R: RecursiveArray<T>>( self, array: R ) -> RecursiveArrayConcatenation<T, Self, R>
appends a recrusive array to the back of this array.
sourcefn push_front(
self,
item: T
) -> RecursiveArrayConcatenation<T, RecursiveArraySingleItem<T>, Self>
fn push_front( self, item: T ) -> RecursiveArrayConcatenation<T, RecursiveArraySingleItem<T>, Self>
appends an element to the fron of this array.
sourcefn append_front<R: RecursiveArray<T>>(
self,
array: R
) -> RecursiveArrayConcatenation<T, R, Self>
fn append_front<R: RecursiveArray<T>>( self, array: R ) -> RecursiveArrayConcatenation<T, R, Self>
appends a recrusive array to the front of this array.