Array

Trait Array 

Source
pub trait Array<T, const N: usize>:
    From<[T; N]>
    + Into<[T; N]>
    + Index<usize, Output = T>
    + IndexMut<usize, Output = T> {
    const DIMENSION: usize = N;

    // Required methods
    fn array(&self) -> &[T; N];
    fn array_mut(&mut self) -> &mut [T; N];

    // Provided methods
    fn to_array_resized<const M: usize>(self) -> [T; M]
       where T: Default { ... }
    fn to_array_resized_with_value<const M: usize>(self, fill: T) -> [T; M]
       where T: Clone { ... }
}
Expand description

An array that is indexable, without any information if the type and the size are generic. Check ArrayWithType and ArrayWithSize for editable generic type.

Provided Associated Constants§

Required Methods§

Source

fn array(&self) -> &[T; N]

Source

fn array_mut(&mut self) -> &mut [T; N]

Provided Methods§

Source

fn to_array_resized<const M: usize>(self) -> [T; M]
where T: Default,

Fill non existing component with Default

Source

fn to_array_resized_with_value<const M: usize>(self, fill: T) -> [T; M]
where T: Clone,

Fill non existing component with the Cloned given value

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.

Implementations on Foreign Types§

Source§

impl<T, const N: usize> Array<T, N> for [T; N]

Source§

fn array(&self) -> &[T; N]

Source§

fn array_mut(&mut self) -> &mut [T; N]

Implementors§