Skip to content

Commit

Permalink
Rollup merge of rust-lang#78735 - danielhenrymantilla:simplify-unsafe…
Browse files Browse the repository at this point in the history
…cell-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`
  • Loading branch information
JohnTitor authored Nov 5, 2020
2 parents 08e60c6 + 69e5729 commit 41d11a1
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions library/core/src/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 41d11a1

Please sign in to comment.