Use MaybeUninit::write in functor.rs

MaybeUninit::write is stable as of 1.55.0.
This commit is contained in:
est31 2021-08-30 17:23:08 +02:00
parent 47ab5f7ce2
commit 403b80d32e

View File

@ -26,7 +26,7 @@ impl<T> IdFunctor for Box<T> {
// inverse of `Box::assume_init()` and should be safe.
let mut raw: Box<mem::MaybeUninit<T>> = Box::from_raw(raw.cast());
// SAFETY: Write the mapped value back into the `Box`.
ptr::write(raw.as_mut_ptr(), f(value));
raw.write(f(value));
// SAFETY: We just initialized `raw`.
raw.assume_init()
}