pub const fn repeat_with<T, F>(f: F) -> RepeatWith<F>Expand description
Initializes a slice by calling a closure for each element.
RepeatWith allows you to initialize a slice where each element is produced
by calling a closure with the element’s index. This provides a flexible way
to create complex slice initializations.
§Examples
Creating an array of indices:
use placid::prelude::*;
let mut uninit = uninit!([usize; 5]);
let owned = uninit.write(init::repeat_with(|i| i * 2));
assert_eq!(&*owned, &[0, 2, 4, 6, 8]);