Skip to content

Commit

Permalink
sync: expand Debug for Mutex<T> impl to unsized T (tokio-rs#4134)
Browse files Browse the repository at this point in the history
  • Loading branch information
steffahn authored and suikammd committed Oct 7, 2021
1 parent b49a55b commit 24e59ac
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tokio/src/sync/mutex.rs
Expand Up @@ -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()
Expand Down

0 comments on commit 24e59ac

Please sign in to comment.