pub trait ArrayExt<T>: Sized {
    // Required methods
    fn from_fn<F>(cb: F) -> Self
       where F: FnMut(usize) -> T;
    fn from_slice(slice: &[T]) -> Result<Self, TryFromSliceError>
       where T: Copy;
}
Expand description

Extension trait with helper functions for core arrays.

Required Methods§

source

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

Create array using the given callback function for each element.

source

fn from_slice(slice: &[T]) -> Result<Self, TryFromSliceError>
where T: Copy,

Create array from a slice, returning TryFromSliceError if the slice length does not match the array length.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

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

source§

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

source§

fn from_slice(slice: &[T]) -> Result<Self, TryFromSliceError>
where T: Copy,

Implementors§