2626//!
2727//! `MTLock` is a mutex which disappears if cfg!(parallel_queries) is false.
2828//!
29+ //! `MTRef` is a immutable refernce if cfg!(parallel_queries), and an mutable reference otherwise.
30+ //!
2931//! `rustc_erase_owner!` erases a OwningRef owner into Erased or Erased + Send + Sync
3032//! depending on the value of cfg!(parallel_queries).
3133
@@ -126,6 +128,8 @@ cfg_if! {
126128 }
127129 }
128130
131+ pub type MTRef <' a, T > = & ' a mut T ;
132+
129133 #[ derive( Debug ) ]
130134 pub struct MTLock <T >( T ) ;
131135
@@ -151,13 +155,8 @@ cfg_if! {
151155 }
152156
153157 #[ inline( always) ]
154- pub fn borrow( & self ) -> & T {
155- & self . 0
156- }
157-
158- #[ inline( always) ]
159- pub fn borrow_mut( & self ) -> & T {
160- & self . 0
158+ pub fn lock_mut( & mut self ) -> & mut T {
159+ & mut self . 0
161160 }
162161 }
163162
@@ -221,7 +220,37 @@ cfg_if! {
221220 pub use std:: sync:: Arc as Lrc ;
222221 pub use std:: sync:: Weak as Weak ;
223222
224- pub use self :: Lock as MTLock ;
223+ pub type MTRef <' a, T > = & ' a T ;
224+
225+ #[ derive( Debug ) ]
226+ pub struct MTLock <T >( Lock <T >) ;
227+
228+ impl <T > MTLock <T > {
229+ #[ inline( always) ]
230+ pub fn new( inner: T ) -> Self {
231+ MTLock ( Lock :: new( inner) )
232+ }
233+
234+ #[ inline( always) ]
235+ pub fn into_inner( self ) -> T {
236+ self . 0 . into_inner( )
237+ }
238+
239+ #[ inline( always) ]
240+ pub fn get_mut( & mut self ) -> & mut T {
241+ self . 0 . get_mut( )
242+ }
243+
244+ #[ inline( always) ]
245+ pub fn lock( & self ) -> LockGuard <T > {
246+ self . 0 . lock( )
247+ }
248+
249+ #[ inline( always) ]
250+ pub fn lock_mut( & self ) -> LockGuard <T > {
251+ self . lock( )
252+ }
253+ }
225254
226255 use parking_lot:: Mutex as InnerLock ;
227256 use parking_lot:: RwLock as InnerRwLock ;
0 commit comments