Rollup merge of #88492 - est31:maybe_uninit_write, r=wesleywiser

Use MaybeUninit::write in functor.rs

MaybeUninit::write is stable as of 1.55.0.
This commit is contained in:
Mara Bos 2021-08-31 10:41:26 +02:00 committed by GitHub
commit 4adacfd43e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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