pub fn from_fn<F, T>(f: F, len: Option<usize>) -> FromFn<F>Expand description
A slice made by calling a closure on the index.
Analagous to core::iter::from_fn.
ยงExamples
let slice = slice_utils::from_fn(|i| Some(i * i), Some(5));
assert_eq!(slice, [0, 1, 4, 9, 16]);