File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -55,9 +55,20 @@ impl<T> Mutex<T> {
55
55
inner : UnsafeCell :: new ( value) ,
56
56
}
57
57
}
58
- }
59
58
60
- impl < T > Mutex < T > {
59
+ /// Gets a mutable reference to the contained value when the mutex is already uniquely borrowed.
60
+ ///
61
+ /// This does not require locking or a critical section since it takes `&mut self`, which
62
+ /// guarantees unique ownership already.
63
+ pub fn get_mut ( & mut self ) -> & mut T {
64
+ unsafe { & mut * self . inner . get ( ) }
65
+ }
66
+
67
+ /// Unwraps the contained value, consuming the mutex.
68
+ pub fn into_inner ( self ) -> T {
69
+ self . inner . into_inner ( )
70
+ }
71
+
61
72
/// Borrows the data for the duration of the critical section.
62
73
pub fn borrow < ' cs > ( & ' cs self , _cs : CriticalSection < ' cs > ) -> & ' cs T {
63
74
unsafe { & * self . inner . get ( ) }
You can’t perform that action at this time.
0 commit comments