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 splat(value: T) -> Self
       where T: Clone { ... }
    fn any<P>(&self, p: P) -> bool
       where P: FnMut(&T) -> bool { ... }
    fn all<P>(&self, p: P) -> bool
       where P: FnMut(&T) -> bool { ... }
    fn for_each<F>(&self, f: F)
       where F: FnMut(&T) { ... }
    fn for_each_mut<F>(&mut self, f: F)
       where F: FnMut(&mut T) { ... }
    fn slice(&self) -> &[T] { ... }
    fn slice_mut(&mut self) -> &mut [T] { ... }
    fn to_array_with_size<const M: usize>(self) -> [T; M]
       where T: Default { ... }
    fn to_array_with_size_filled_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 ArrayWithGenericType and ArrayWithGenericSize 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 splat(value: T) -> Self
where T: Clone,

Source

fn any<P>(&self, p: P) -> bool
where P: FnMut(&T) -> bool,

True if the predicate is true for at least one component

Source

fn all<P>(&self, p: P) -> bool
where P: FnMut(&T) -> bool,

True if the predicate is true for all component

Source

fn for_each<F>(&self, f: F)
where F: FnMut(&T),

Source

fn for_each_mut<F>(&mut self, f: F)
where F: FnMut(&mut T),

Source

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

Source

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

Source

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

Fill non existing component with Default

Source

fn to_array_with_size_filled_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§