Simplify the implementation of get_mut (no unsafe)

This commit is contained in:
Daniel Henry-Mantilla 2020-11-04 14:54:22 +01:00
parent 56293097f7
commit 69e5729c58

View file

@ -1733,8 +1733,7 @@ impl<T: ?Sized> UnsafeCell<T> {
#[inline]
#[unstable(feature = "unsafe_cell_get_mut", issue = "76943")]
pub fn get_mut(&mut self) -> &mut T {
// SAFETY: (outer) `&mut` guarantees unique access.
unsafe { &mut *self.get() }
&mut self.value
}
/// Gets a mutable pointer to the wrapped value.