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§
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.
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.