Function unarray::build_array
source · [−]Expand description
Build an array with a function that creates elements based on their index
let array: [usize; 5] = build_array(|i| i * 2);
assert_eq!(array, [0, 2, 4, 6, 8]);For builder functions which might fail, consider using build_array_result or
build_array_option