Use MaybeUninit::write in functor.rs
MaybeUninit::write is stable as of 1.55.0.
This commit is contained in:
parent
47ab5f7ce2
commit
403b80d32e
1 changed files with 1 additions and 1 deletions
|
@ -26,7 +26,7 @@ impl<T> IdFunctor for Box<T> {
|
||||||
// inverse of `Box::assume_init()` and should be safe.
|
// inverse of `Box::assume_init()` and should be safe.
|
||||||
let mut raw: Box<mem::MaybeUninit<T>> = Box::from_raw(raw.cast());
|
let mut raw: Box<mem::MaybeUninit<T>> = Box::from_raw(raw.cast());
|
||||||
// SAFETY: Write the mapped value back into the `Box`.
|
// 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`.
|
// SAFETY: We just initialized `raw`.
|
||||||
raw.assume_init()
|
raw.assume_init()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue