Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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) };


That's correct.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: