sync: use UnsafeCell::get_mut in Mutex::get_mut and RwLock::get_mut (#7569)

This commit is contained in:
Roman 2025-09-04 11:39:28 -03:00 committed by GitHub
parent d1e06f831e
commit a99a351802
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 8 deletions

View File

@ -716,10 +716,7 @@ impl<T: ?Sized> Mutex<T> {
/// }
/// ```
pub fn get_mut(&mut self) -> &mut T {
unsafe {
// Safety: This is https://github.com/rust-lang/rust/pull/76936
&mut *self.c.get()
}
self.c.get_mut()
}
/// Attempts to acquire the lock, and returns [`TryLockError`] if the lock

View File

@ -1073,10 +1073,7 @@ impl<T: ?Sized> RwLock<T> {
/// }
/// ```
pub fn get_mut(&mut self) -> &mut T {
unsafe {
// Safety: This is https://github.com/rust-lang/rust/pull/76936
&mut *self.c.get()
}
self.c.get_mut()
}
/// Consumes the lock, returning the underlying data.