pub fn uninit_buf<T, const N: usize>() -> [MaybeUninit<T>; N]
Expand description
Create an array of unintialized memory
This function is just a safe wrapper around MaybeUninit::uninit().assume_init()
, which is
safe when used to create a [MaybeUninit<T>; N]
, since this type explicitly requires no
initialization
let mut buffer = uninit_buf::<i32, 1000>();
for elem in &mut buffer {
elem.write(123);
}
let result = unsafe { mark_initialized(buffer) };
assert_eq!(result, [123; 1000])
This is similar to the nightly-only core::mem::MaybeUninit::uninit_array