mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
Use MaybeUninit::write in functor.rs
MaybeUninit::write is stable as of 1.55.0.
This commit is contained in:
parent
47ab5f7ce2
commit
403b80d32e
@ -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()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user