Skip to content

Commit 29fad21

Browse files
authored
Rollup merge of #78735 - danielhenrymantilla:simplify-unsafecell-getmut, r=RalfJung
Simplify the implementation of `get_mut` (no unsafe) Quick PR to reduce one use of `unsafe` pointed out in the previous PR r? ````@RalfJung````
2 parents 8640360 + 69e5729 commit 29fad21

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

library/core/src/cell.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1733,8 +1733,7 @@ impl<T: ?Sized> UnsafeCell<T> {
17331733
#[inline]
17341734
#[unstable(feature = "unsafe_cell_get_mut", issue = "76943")]
17351735
pub fn get_mut(&mut self) -> &mut T {
1736-
// SAFETY: (outer) `&mut` guarantees unique access.
1737-
unsafe { &mut *self.get() }
1736+
&mut self.value
17381737
}
17391738

17401739
/// Gets a mutable pointer to the wrapped value.

0 commit comments

Comments
 (0)