Function init_slice

Source
pub fn init_slice<T, F: FnMut(usize) -> T>(
    s: &mut [MaybeUninit<T>],
    f: F,
) -> &mut [T]
Expand description

Initialize all the elements in the slice with the result of calling the function with the index in the slice.

If this unwinds, all the already initalized elements will be dropped, minimizing the risk of accidental resource leaks