Skip to main content

ArrayLike

Trait ArrayLike 

Source
pub trait ArrayLike<Idx>: Index<Idx, Output = Self::Elem> + IndexMut<Idx, Output = Self::Elem> {
    type Elem;

    const LEN: usize;

    // Required method
    fn from_fn<F: FnMut(Idx) -> Self::Elem>(cb: F) -> Self;
}
Expand description

A helper trait for array types which can be indexed and iterated, with compile time known length. Use of this trait can be removed if generic_const_exprs is ever stabilized.

Required Associated Constants§

Source

const LEN: usize

Length of array, known at compile time.

Required Associated Types§

Source

type Elem

Type of elements in the array

Required Methods§

Source

fn from_fn<F: FnMut(Idx) -> Self::Elem>(cb: F) -> Self

Creates an array of the given length and type by repeatly calling the given function.

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> ArrayLike<usize> for [T; N]

Source§

const LEN: usize = N

Source§

type Elem = T

Source§

fn from_fn<F: FnMut(usize) -> T>(cb: F) -> Self

Implementors§