summaryrefslogtreecommitdiffstats
path: root/tokio/src/sync/mutex.rs
diff options
context:
space:
mode:
authoryim7 <yimchiu7@gmail.com>2019-12-18 14:02:31 +0800
committerCarl Lerche <me@carllerche.com>2019-12-17 22:02:31 -0800
commite5b99b0f7a12ca27b390535b8628f87a61a08eb6 (patch)
treef4fcd3b997b9a7b5ca4f7233ea6469204d5285a9 /tokio/src/sync/mutex.rs
parent83cd754bc80dc8718b65fd32f54e53b4d7ba8332 (diff)
sync: print MutexGuard inner value for debugging (#1961)
Diffstat (limited to 'tokio/src/sync/mutex.rs')
-rw-r--r--tokio/src/sync/mutex.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/tokio/src/sync/mutex.rs b/tokio/src/sync/mutex.rs
index 35e13300..bee00df4 100644
--- a/tokio/src/sync/mutex.rs
+++ b/tokio/src/sync/mutex.rs
@@ -61,7 +61,6 @@ pub struct Mutex<T> {
///
/// The lock is automatically released whenever the guard is dropped, at which point `lock`
/// will succeed yet again.
-#[derive(Debug)]
pub struct MutexGuard<'a, T> {
lock: &'a Mutex<T>,
permit: semaphore::Permit,
@@ -176,6 +175,12 @@ impl<'a, T> DerefMut for MutexGuard<'a, T> {
}
}
+impl<'a, T: fmt::Debug> fmt::Debug for MutexGuard<'a, T> {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ fmt::Debug::fmt(&**self, f)
+ }
+}
+
impl<'a, T: fmt::Display> fmt::Display for MutexGuard<'a, T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Display::fmt(&**self, f)