Trait slice_of_array::SliceArrayExt
[−]
[src]
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,
{ ... }
}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
fn as_array<V: IsSliceomorphic<Element = T>>(&self) -> &V
View &[T] as &[T; n].
fn as_mut_array<V: IsSliceomorphic<Element = T>>(&mut self) -> &mut V
View &mut [T] as &mut [T;n].
Provided Methods
fn to_array<V: IsSliceomorphic<Element = T>>(&self) -> V where
V: Clone,
V: Clone,
Clone &[T] to [T; n].
This is provided because .as_array().clone() tends to cause trouble for
type inference.
Implementations on Foreign Types
impl<T> SliceArrayExt<T> for [T][src]
fn as_array<V: IsSliceomorphic<Element = T>>(&self) -> &V[src]
fn as_mut_array<V: IsSliceomorphic<Element = T>>(&mut self) -> &mut V[src]
fn to_array<V: IsSliceomorphic<Element = T>>(&self) -> V where
V: Clone, [src]
V: Clone,