Skip to main content

BoundedFromFn

Trait BoundedFromFn 

Source
pub trait BoundedFromFn<T, N: Get<u32>>: Sized {
    // Required method
    fn from_fn(len: usize, f: impl FnMut(usize) -> T) -> Self;

    // Provided methods
    fn from_fn_fill(f: impl FnMut(usize) -> T) -> Self { ... }
    fn default_fill() -> Self
       where T: Default { ... }
}
Expand description

Constructor for bounded vectors built from an index function.

Required Methods§

Source

fn from_fn(len: usize, f: impl FnMut(usize) -> T) -> Self

Build a vector of len elements, where element i is f(i).

Panics if len exceeds the bound.

Provided Methods§

Source

fn from_fn_fill(f: impl FnMut(usize) -> T) -> Self

Build a vector filled up to the bound, where element i is f(i).

Source

fn default_fill() -> Self
where T: Default,

Build a vector filled up to the bound with default elements.

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, N: Get<u32>> BoundedFromFn<T, N> for BoundedVec<T, N>

Source§

fn from_fn(len: usize, f: impl FnMut(usize) -> T) -> Self

Implementors§