@@ -25,17 +25,17 @@ mod lazy_lock;
2525/// Refer to the [crate-level][`crate`] documentation for the differences between this struct and
2626/// the one it wraps.
2727#[ derive( Debug , Default ) ]
28- pub struct Mutex < T > {
29- inner : sync:: Mutex < T > ,
28+ pub struct Mutex < T : ?Sized > {
3029 id : LazyMutexId ,
30+ inner : sync:: Mutex < T > ,
3131}
3232
3333/// Wrapper for [`std::sync::MutexGuard`].
3434///
3535/// Refer to the [crate-level][`crate`] documentation for the differences between this struct and
3636/// the one it wraps.
3737#[ derive( Debug ) ]
38- pub struct MutexGuard < ' a , T > {
38+ pub struct MutexGuard < ' a , T : ? Sized > {
3939 inner : sync:: MutexGuard < ' a , T > ,
4040 _mutex : BorrowedMutex < ' a > ,
4141}
@@ -71,7 +71,9 @@ impl<T> Mutex<T> {
7171 id : LazyMutexId :: new ( ) ,
7272 }
7373 }
74+ }
7475
76+ impl < T : ?Sized > Mutex < T > {
7577 /// Wrapper for [`std::sync::Mutex::lock`].
7678 ///
7779 /// # Panics
@@ -123,12 +125,15 @@ impl<T> Mutex<T> {
123125 }
124126
125127 /// Unwrap the mutex and return its inner value.
126- pub fn into_inner ( self ) -> LockResult < T > {
128+ pub fn into_inner ( self ) -> LockResult < T >
129+ where
130+ T : Sized ,
131+ {
127132 self . inner . into_inner ( )
128133 }
129134}
130135
131- impl < T > PrivateTraced for Mutex < T > {
136+ impl < T : ? Sized > PrivateTraced for Mutex < T > {
132137 fn get_id ( & self ) -> & crate :: MutexId {
133138 & self . id
134139 }
@@ -140,21 +145,21 @@ impl<T> From<T> for Mutex<T> {
140145 }
141146}
142147
143- impl < T > Deref for MutexGuard < ' _ , T > {
148+ impl < T : ? Sized > Deref for MutexGuard < ' _ , T > {
144149 type Target = T ;
145150
146151 fn deref ( & self ) -> & Self :: Target {
147152 & self . inner
148153 }
149154}
150155
151- impl < T > DerefMut for MutexGuard < ' _ , T > {
156+ impl < T : ? Sized > DerefMut for MutexGuard < ' _ , T > {
152157 fn deref_mut ( & mut self ) -> & mut Self :: Target {
153158 & mut self . inner
154159 }
155160}
156161
157- impl < T : fmt:: Display > fmt:: Display for MutexGuard < ' _ , T > {
162+ impl < T : fmt:: Display + ? Sized > fmt:: Display for MutexGuard < ' _ , T > {
158163 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
159164 self . inner . fmt ( f)
160165 }
@@ -274,9 +279,9 @@ impl Condvar {
274279
275280/// Wrapper for [`std::sync::RwLock`].
276281#[ derive( Debug , Default ) ]
277- pub struct RwLock < T > {
278- inner : sync:: RwLock < T > ,
282+ pub struct RwLock < T : ?Sized > {
279283 id : LazyMutexId ,
284+ inner : sync:: RwLock < T > ,
280285}
281286
282287/// Hybrid wrapper for both [`std::sync::RwLockReadGuard`] and [`std::sync::RwLockWriteGuard`].
@@ -300,7 +305,9 @@ impl<T> RwLock<T> {
300305 id : LazyMutexId :: new ( ) ,
301306 }
302307 }
308+ }
303309
310+ impl < T : ?Sized > RwLock < T > {
304311 /// Wrapper for [`std::sync::RwLock::read`].
305312 ///
306313 /// # Panics
@@ -377,12 +384,15 @@ impl<T> RwLock<T> {
377384 }
378385
379386 /// Unwrap the mutex and return its inner value.
380- pub fn into_inner ( self ) -> LockResult < T > {
387+ pub fn into_inner ( self ) -> LockResult < T >
388+ where
389+ T : Sized ,
390+ {
381391 self . inner . into_inner ( )
382392 }
383393}
384394
385- impl < T > PrivateTraced for RwLock < T > {
395+ impl < T : ? Sized > PrivateTraced for RwLock < T > {
386396 fn get_id ( & self ) -> & crate :: MutexId {
387397 & self . id
388398 }
@@ -396,6 +406,7 @@ impl<T> From<T> for RwLock<T> {
396406
397407impl < L , T > Deref for TracingRwLockGuard < ' _ , L >
398408where
409+ T : ?Sized ,
399410 L : Deref < Target = T > ,
400411{
401412 type Target = T ;
@@ -405,8 +416,9 @@ where
405416 }
406417}
407418
408- impl < T , L > DerefMut for TracingRwLockGuard < ' _ , L >
419+ impl < L , T > DerefMut for TracingRwLockGuard < ' _ , L >
409420where
421+ T : ?Sized ,
410422 L : Deref < Target = T > + DerefMut ,
411423{
412424 fn deref_mut ( & mut self ) -> & mut Self :: Target {
0 commit comments