From 5ac431fb084e32b8ea86b800c98738ce49ddab37 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 12 Dec 2020 13:37:29 +0000 Subject: [PATCH] WriterPanicked: Use debug_struct Co-authored-by: Ivan Tham --- library/std/src/io/buffered/bufwriter.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/library/std/src/io/buffered/bufwriter.rs b/library/std/src/io/buffered/bufwriter.rs index 94e625b9410..4319febbf91 100644 --- a/library/std/src/io/buffered/bufwriter.rs +++ b/library/std/src/io/buffered/bufwriter.rs @@ -382,7 +382,9 @@ impl fmt::Display for WriterPanicked { #[unstable(feature = "bufwriter_into_raw_parts", issue = "none")] impl fmt::Debug for WriterPanicked { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "WriterPanicked{{..buf.len={}..}}", self.buf.len()) + fmt.debug_struct("WriterPanicked") + .field("buffer", &format_args!("{}/{}", self.buf.len(), self.buf.capacity())) + .finish() } }