diff options
| author | Mara Bos <m-ou.se@m-ou.se> | 2019-01-17 18:57:46 +0100 |
|---|---|---|
| committer | Mara Bos <m-ou.se@m-ou.se> | 2019-01-17 19:00:48 +0100 |
| commit | 7b557119883685e541d555135fb81c0dc10e2752 (patch) | |
| tree | c1da82002754da3f3ea544e5b3a148e2bc3b8eb8 /src/libstd/sync | |
| parent | daa53a52a2667533d5fe59bfcc5b8614b79c3d31 (diff) | |
Make MutexGuard's Debug implementation more useful.
Fixes #57702.
Diffstat (limited to 'src/libstd/sync')
| -rw-r--r-- | src/libstd/sync/mutex.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/libstd/sync/mutex.rs b/src/libstd/sync/mutex.rs index 856bb260424..e4cc2979207 100644 --- a/src/libstd/sync/mutex.rs +++ b/src/libstd/sync/mutex.rs @@ -450,9 +450,13 @@ impl<'a, T: ?Sized> Drop for MutexGuard<'a, T> { #[stable(feature = "std_debug", since = "1.16.0")] impl<'a, T: ?Sized + fmt::Debug> fmt::Debug for MutexGuard<'a, T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("MutexGuard") - .field("lock", &self.__lock) - .finish() + struct MutexFmt<'a, T: ?Sized>(&'a MutexGuard<'a, T>); + impl<'a, T: ?Sized + fmt::Debug> fmt::Debug for MutexFmt<'a, T> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Mutex").field("data", &&*self.0).finish() + } + } + f.debug_struct("MutexGuard").field("lock", &MutexFmt(self)).finish() } } |
