Trait Array

Source
pub trait Array<T> {
    // Required method
    fn from_fn<F>(f: F) -> Self
       where F: FnMut(usize) -> T;

    // Provided method
    fn from_iter<I: Iterator<Item = T>>(iter: I) -> Self
       where Self: Sized { ... }
}
Expand description

Implemented by arrays of different lengths.

Required Methods§

Source

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

Creates array from a function of each component index.

Provided Methods§

Source

fn from_iter<I: Iterator<Item = T>>(iter: I) -> Self
where Self: Sized,

Creates an array from an iterator. Will fail if the iterator does not contain enough elements.

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> Array<T> for [T; 2]

Source§

fn from_fn<F>(f: F) -> [T; 2]
where F: FnMut(usize) -> T,

Source§

impl<T> Array<T> for [T; 3]

Source§

fn from_fn<F>(f: F) -> [T; 3]
where F: FnMut(usize) -> T,

Source§

impl<T> Array<T> for [T; 4]

Source§

fn from_fn<F>(f: F) -> [T; 4]
where F: FnMut(usize) -> T,

Source§

impl<T> Array<T> for [T; 16]

Source§

fn from_fn<F>(f: F) -> [T; 16]
where F: FnMut(usize) -> T,

Implementors§