diff options
| author | Mara Bos <m-ou.se@m-ou.se> | 2021-03-27 13:31:17 +0100 |
|---|---|---|
| committer | Mara Bos <m-ou.se@m-ou.se> | 2021-03-27 13:33:52 +0100 |
| commit | d73015397dc43eb8067644ab2bbb1c2203c795d4 (patch) | |
| tree | 4372dc66d67a28bc9704b6a414bb3bc2d02eea03 /library/std/src | |
| parent | feaac19f1710ebcfecc783d51f52a9b0d8e998f5 (diff) | |
Fix Debug implementation for RwLock{Read,Write}Guard.
This would attempt to print the Debug representation of the lock that the guard has locked, which will try to lock again, fail, and just print "<locked>" unhelpfully. After this change, this just prints the contents of the mutex, like the other smart pointers (and MutexGuard) do.
Diffstat (limited to 'library/std/src')
| -rw-r--r-- | library/std/src/sync/rwlock.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/library/std/src/sync/rwlock.rs b/library/std/src/sync/rwlock.rs index 0298f59228c..c6c753b103f 100644 --- a/library/std/src/sync/rwlock.rs +++ b/library/std/src/sync/rwlock.rs @@ -473,7 +473,7 @@ impl<'rwlock, T: ?Sized> RwLockWriteGuard<'rwlock, T> { #[stable(feature = "std_debug", since = "1.16.0")] impl<T: fmt::Debug> fmt::Debug for RwLockReadGuard<'_, T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("RwLockReadGuard").field("lock", &self.lock).finish() + (**self).fmt(f) } } @@ -487,7 +487,7 @@ impl<T: ?Sized + fmt::Display> fmt::Display for RwLockReadGuard<'_, T> { #[stable(feature = "std_debug", since = "1.16.0")] impl<T: fmt::Debug> fmt::Debug for RwLockWriteGuard<'_, T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("RwLockWriteGuard").field("lock", &self.lock).finish() + (**self).fmt(f) } } |
