about summary refs log tree commit diff
diff options
context:
space:
mode:
authorChayim Refael Friedman <chayimfr@gmail.com>2021-12-30 05:04:44 +0200
committerGitHub <noreply@github.com>2021-12-30 05:04:44 +0200
commite86ecdf9fe2d60dad52c1e60657ed749c2196c5b (patch)
tree112f25fd4ce7ea51c2789140432095ed7dba064c
parentd331cb710f0dd969d779510a49a3bafc7f78a54e (diff)
downloadrust-e86ecdf9fe2d60dad52c1e60657ed749c2196c5b.tar.gz
rust-e86ecdf9fe2d60dad52c1e60657ed749c2196c5b.zip
Use `UnsafeCell::get_mut()` in `core::lazy::OnceCell::get_mut()`
This removes one unnecessary `unsafe` block.
-rw-r--r--library/core/src/lazy.rs3
1 files changed, 1 insertions, 2 deletions
diff --git a/library/core/src/lazy.rs b/library/core/src/lazy.rs
index 2b8a5f3cbf3..788f0cce01b 100644
--- a/library/core/src/lazy.rs
+++ b/library/core/src/lazy.rs
@@ -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`.