Skip to main content

ArrayLike

Trait ArrayLike 

Source
pub trait ArrayLike<T>: Index<usize, Output = T> {
    const LEN: usize;

    // Required methods
    fn create(create_element: impl FnMut() -> T) -> Self;
    fn iter(&self) -> Iter<'_, T>;
}
Expand description

Abstracts over fixed-length arrays (and similar types) with an element type T.

Provides iter and Index rather than Deref or AsRef<[T]> to allow for alternate forms of indexing, for which exposing a slice could be confusing. See OneBased.

Required Associated Constants§

Required Methods§

Source

fn create(create_element: impl FnMut() -> T) -> Self

Source

fn iter(&self) -> Iter<'_, T>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T, const LEN: usize> ArrayLike<T> for [T; LEN]

Source§

const LEN: usize = LEN

Source§

fn create(create_element: impl FnMut() -> T) -> Self

Source§

fn iter(&self) -> Iter<'_, T>

Implementors§

Source§

impl<T, Ts> ArrayLike<T> for OneBased<Ts>
where Ts: ArrayLike<T>,

Source§

const LEN: usize = Ts::LEN