Trait slice_of_array::SliceArrayExt
source · pub trait SliceArrayExt<T> {
fn as_array<V: IsSliceomorphic<Element = T>>(&self) -> &V;
fn as_mut_array<V: IsSliceomorphic<Element = T>>(&mut self) -> &mut V;
fn to_array<V: IsSliceomorphic<Element = T>>(&self) -> V
where
V: Clone,
{ ... }
}Expand description
Permits viewing a slice as an array.
The output array length can often be inferred.
When it is not, a turbofish can be used: .as_array::<[_; 3]>().
Panics
All methods panic if the slice is not exactly the requested length.
Implementors
The methods are available on &[T] and &mut [T] for all T.
Of course, they are also available on Vec<T> and any other type
that derefs or unsizes to [T].
Notice
The existence of this trait is an implementation detail.
Please do NOT use this trait as a generic bound in your code.
Required Methods
sourcefn as_array<V: IsSliceomorphic<Element = T>>(&self) -> &V
fn as_array<V: IsSliceomorphic<Element = T>>(&self) -> &V
View &[T] as &[T; n].
sourcefn as_mut_array<V: IsSliceomorphic<Element = T>>(&mut self) -> &mut V
fn as_mut_array<V: IsSliceomorphic<Element = T>>(&mut self) -> &mut V
View &mut [T] as &mut [T; n].
Provided Methods
sourcefn to_array<V: IsSliceomorphic<Element = T>>(&self) -> Vwhere
V: Clone,
fn to_array<V: IsSliceomorphic<Element = T>>(&self) -> Vwhere
V: Clone,
Clone &[T] to [T; n].
This is provided because .as_array().clone() tends to cause trouble for
type inference.