1
Fork 0

Rollup merge of #92427 - ChayimFriedman2:patch-1, r=kennytm

Use `UnsafeCell::get_mut()` in `core::lazy::OnceCell::get_mut()`

This removes one unnecessary `unsafe` block.
This commit is contained in:
Matthias Krüger 2021-12-30 13:12:36 +01:00 committed by GitHub
commit c10fe04484
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -102,8 +102,7 @@ impl<T> OnceCell<T> {
/// Returns `None` if the cell is empty.
#[unstable(feature = "once_cell", issue = "74465")]
pub fn get_mut(&mut self) -> Option<&mut T> {
// SAFETY: Safe because we have unique access
unsafe { &mut *self.inner.get() }.as_mut()
self.inner.get_mut().as_mut()
}
/// Sets the contents of the cell to `value`.