Trait SliceFlatExt

Source
pub trait SliceFlatExt<T> {
    // Required methods
    fn flat(&self) -> &[T];
    fn flat_mut(&mut self) -> &mut [T];
}
Expand description

Permits viewing a slice of arrays as a flat slice.

§Panics

Will panic if the new length exceeds usize::MAX. (in practice, this can only happen with zero-sized types)

§Implementors

The methods are available on &[[T; n]] and &mut [[T; n]] for all T and n. Of course, they are also available on Vec<[T; n]> and any other type that derefs or unsizes to [[T; n]].

&[[T; 0]] does support being flattened into an empty slice, however, please do mind that the inverse operation SliceNestExt::nest will panic (as it cannot possibly recover the original length of the slice).

§Notice

The existence of this trait is an implementation detail. Future versions may split it up, merge or rename it. Therefore, please do NOT use this trait as a generic bound in your code.

(Prefer [V] where V: IsSliceomorphic<Element=T> instead)

Required Methods§

Source

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

View &[[T; n]] as &[T].

Source

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

View &mut [[T; n]] as &mut [T]

Implementations on Foreign Types§

Source§

impl<V: IsSliceomorphic> SliceFlatExt<<V as IsSliceomorphic>::Element> for [V]

Source§

fn flat(&self) -> &[V::Element]

Source§

fn flat_mut(&mut self) -> &mut [V::Element]

Implementors§