Function brownstone::build_indexed[][src]

pub fn build_indexed<T, F, const N: usize>(next_value: F) -> [T; N] where
    F: FnMut(usize) -> T, 
Expand description

Build a fixed-size array with an initializer function. The initializer is called once for each item in the length of the array, and the completed array is returned.

Each time the method is called, it is provided with the index of the element being produced.

Example

let array: [usize; 5] = brownstone::build_indexed(|i| i + 1);
assert_eq!(array, [1, 2, 3, 4, 5]);