Skip to content

Commit e86ecdf

Browse files
Use UnsafeCell::get_mut() in core::lazy::OnceCell::get_mut()
This removes one unnecessary `unsafe` block.
1 parent d331cb7 commit e86ecdf

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

Diff for: library/core/src/lazy.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,7 @@ impl<T> OnceCell<T> {
102102
/// Returns `None` if the cell is empty.
103103
#[unstable(feature = "once_cell", issue = "74465")]
104104
pub fn get_mut(&mut self) -> Option<&mut T> {
105-
// SAFETY: Safe because we have unique access
106-
unsafe { &mut *self.inner.get() }.as_mut()
105+
self.inner.get_mut().as_mut()
107106
}
108107

109108
/// Sets the contents of the cell to `value`.

0 commit comments

Comments
 (0)