Closed kupiakos closed 10 months ago
Ah, there's a key distinction between init_with
and fill_with
: fill_with
takes a FnMut() -> T
while init_with
takes an IntoIterator<Item = T>
. The former guarantees that everything is filled. iter::from_fn
plus a per-item unwrap
is equivalent to the FnMut() -> T
.
The planned change:
fill
is added to .clone()
each element.fill_with
takes an FnMut() -> T
and guarantees all elements are initialized.init_with
is deprecated and replaced with fill_with_iter
. It remains capable of partial initialization.
This would make it much easier to understand and switch from
&mut [u8]
toOut<[u8]>