Add .into_inner() and .get_mut() to Mutex

This commit is contained in:
Joakim Hulthe 2022-09-16 10:32:43 +02:00
parent 9794bc59cc
commit 70a3b85acc
No known key found for this signature in database
GPG key ID: 2C3E26A7FE602773

View file

@ -111,6 +111,20 @@ where
Ok(MutexGuard { mutex: self })
}
/// Consumes this mutex, returning the underlying data.
pub fn into_inner(self) -> T
where T: Sized {
self.inner.into_inner()
}
/// Returns a mutable reference to the underlying data.
///
/// Since this call borrows the Mutex mutably, no actual locking needs to
/// take place -- the mutable borrow statically guarantees no locks exist.
pub fn get_mut(&mut self) -> &mut T {
self.inner.get_mut()
}
}
/// Async mutex guard.