mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-29 00:00:11 +02:00
sync: use UnsafeCell::get_mut in Mutex::get_mut and RwLock::get_mut (#7569)
This commit is contained in:
@@ -716,10 +716,7 @@ impl<T: ?Sized> Mutex<T> {
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub fn get_mut(&mut self) -> &mut T {
|
pub fn get_mut(&mut self) -> &mut T {
|
||||||
unsafe {
|
self.c.get_mut()
|
||||||
// Safety: This is https://github.com/rust-lang/rust/pull/76936
|
|
||||||
&mut *self.c.get()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Attempts to acquire the lock, and returns [`TryLockError`] if the lock
|
/// Attempts to acquire the lock, and returns [`TryLockError`] if the lock
|
||||||
|
|||||||
@@ -1073,10 +1073,7 @@ impl<T: ?Sized> RwLock<T> {
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub fn get_mut(&mut self) -> &mut T {
|
pub fn get_mut(&mut self) -> &mut T {
|
||||||
unsafe {
|
self.c.get_mut()
|
||||||
// Safety: This is https://github.com/rust-lang/rust/pull/76936
|
|
||||||
&mut *self.c.get()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Consumes the lock, returning the underlying data.
|
/// Consumes the lock, returning the underlying data.
|
||||||
|
|||||||
Reference in New Issue
Block a user