sync: expand Debug for Mutex<T> impl to unsized T (#4134)

This commit is contained in:
Frank Steffahn
2021-09-26 12:29:08 +02:00
committed by GitHub
parent dee3236c97
commit 1073f6e8be
+2 -2
View File
@@ -496,14 +496,14 @@ where
}
}
impl<T> std::fmt::Debug for Mutex<T>
impl<T: ?Sized> std::fmt::Debug for Mutex<T>
where
T: std::fmt::Debug,
{
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let mut d = f.debug_struct("Mutex");
match self.try_lock() {
Ok(inner) => d.field("data", &*inner),
Ok(inner) => d.field("data", &&*inner),
Err(_) => d.field("data", &format_args!("<locked>")),
};
d.finish()