Use `MaybeUninit::zeroed` for gap-filling in `bytes_to_data`
const_maybe_uninit_assume_init,
const_maybe_uninit_assume_init_read,
const_maybe_uninit_uninit_array,
+ const_maybe_uninit_zeroed,
const_mut_refs,
const_precise_live_drops,
const_ptr_is_null,
@@ -2689,6 +2690,12 @@ impl<const N: usize> StaticVec<u8, N> {
res[i] = MaybeUninit::new(values[i]);
i += 1;
}
+ // Fill in any remaining "gaps", or do nothing if `values.len()` is the same as `N`.
+ let mut i = values.len();
+ while i < N {
+ res[i] = MaybeUninit::zeroed();
+ i += 1;
+ }
// Convert `res` from an instance of `[MaybeUninit<u8>; N]` to one of `[u8; N]`, and then return
// it as an instance of `MaybeUninit<[u8; N]>` that can be used to construct a `StaticVec`.
MaybeUninit::new(unsafe { MaybeUninit::array_assume_init(res) })
