Skip to content

Commit 2e9deed

Browse files
committed
Simplify Debug implementation of MutexGuard.
Just transparently print the guarded data, instead of wrapping it in `MutexGuard { lock: Mutex { data: ... } }`.
1 parent 7b55711 commit 2e9deed

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

src/libstd/sync/mutex.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -450,13 +450,7 @@ impl<'a, T: ?Sized> Drop for MutexGuard<'a, T> {
450450
#[stable(feature = "std_debug", since = "1.16.0")]
451451
impl<'a, T: ?Sized + fmt::Debug> fmt::Debug for MutexGuard<'a, T> {
452452
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
453-
struct MutexFmt<'a, T: ?Sized>(&'a MutexGuard<'a, T>);
454-
impl<'a, T: ?Sized + fmt::Debug> fmt::Debug for MutexFmt<'a, T> {
455-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
456-
f.debug_struct("Mutex").field("data", &&*self.0).finish()
457-
}
458-
}
459-
f.debug_struct("MutexGuard").field("lock", &MutexFmt(self)).finish()
453+
fmt::Debug::fmt(&**self, f)
460454
}
461455
}
462456

0 commit comments

Comments
 (0)