by vgatherps · 1y ago · 0 comments
It’s strictly more complicated and slower than the obvious thing to do and only exists to satisfy the abstract machine.
let mut data = Vec::with_capacity(sz);
let mut dst_uninit = data.spare_capacity_mut();
let uninit_src: &[MaybeUninit<T>] = unsafe { transmute(buf) };
dst_uninit.copy_from_slice(uninit_src);
unsafe { data.set_len(sz) };