提交 2e9deed9 编写于 作者: M Mara Bos

Simplify Debug implementation of MutexGuard.

Just transparently print the guarded data, instead of wrapping it in
`MutexGuard { lock: Mutex { data: ... } }`.
上级 7b557119
......@@ -450,13 +450,7 @@ fn drop(&mut self) {
#[stable(feature = "std_debug", since = "1.16.0")]
impl<'a, T: ?Sized + fmt::Debug> fmt::Debug for MutexGuard<'a, T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
struct MutexFmt<'a, T: ?Sized>(&'a MutexGuard<'a, T>);
impl<'a, T: ?Sized + fmt::Debug> fmt::Debug for MutexFmt<'a, T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("Mutex").field("data", &&*self.0).finish()
}
}
f.debug_struct("MutexGuard").field("lock", &MutexFmt(self)).finish()
fmt::Debug::fmt(&**self, f)
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册