From 613d4bd5d56d086ae0fc80746aa111c1ae6b7d2c Mon Sep 17 00:00:00 2001 From: Stepan Koltsov Date: Tue, 21 Mar 2017 07:09:44 +0300 Subject: Reimplement fmt::Debug for Bytes and BytesMut (#84) Standard `Debug` implementation for `[u8]` is comma separated list of numbers. Since large amount of byte strings are in fact ASCII strings or contain a lot of ASCII strings (e. g. HTTP), it is convenient to print strings as ASCII when possible. --- src/bytes.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/bytes.rs') diff --git a/src/bytes.rs b/src/bytes.rs index 954c310..fcec6cc 100644 --- a/src/bytes.rs +++ b/src/bytes.rs @@ -1,5 +1,6 @@ use {IntoBuf, Buf, BufMut}; use buf::Iter; +use debug; use std::{cmp, fmt, mem, hash, ops, slice, ptr, usize}; use std::borrow::Borrow; @@ -722,7 +723,7 @@ impl Eq for Bytes { impl fmt::Debug for Bytes { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - fmt::Debug::fmt(&self.inner.as_ref(), fmt) + fmt::Debug::fmt(&debug::BsDebug(&self.inner.as_ref()), fmt) } } @@ -1260,7 +1261,7 @@ impl Eq for BytesMut { impl fmt::Debug for BytesMut { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - fmt::Debug::fmt(self.inner.as_ref(), fmt) + fmt::Debug::fmt(&debug::BsDebug(&self.inner.as_ref()), fmt) } } -- cgit v1.2.3