3 ms·
In other words the """safe""" stable code looks like this: let mut data = Vec::with_capacity(sz); let mut dst_uninit = data.spare_capacity_mut(); l
by nemothekid 1y ago
In other words the """safe""" stable code looks like this:
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) };
- Arnavion 1y agoThat's correct.