diff options
| author | Mara Bos <m-ou.se@m-ou.se> | 2020-11-05 10:29:54 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-11-05 10:29:54 +0100 |
| commit | 29fad213b2a0e47da07a8fc021e697348d04ebd5 (patch) | |
| tree | 73e1769bdb51e0aa6fc8547e5b19eff60b39ccfb | |
| parent | 8640360870a32ff836a922d68b6988116610edbc (diff) | |
| parent | 69e5729c58481e1a2ce4e4a5982d38deab1fc6b2 (diff) | |
| download | rust-29fad213b2a0e47da07a8fc021e697348d04ebd5.tar.gz rust-29fad213b2a0e47da07a8fc021e697348d04ebd5.zip | |
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````
| -rw-r--r-- | library/core/src/cell.rs | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/library/core/src/cell.rs b/library/core/src/cell.rs index 7140218fa91..ef2a5dd570f 100644 --- a/library/core/src/cell.rs +++ b/library/core/src/cell.rs @@ -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. |
