diff options
author | 2017-03-21 07:09:44 +0300 | |
---|---|---|
committer | 2017-03-20 21:09:44 -0700 | |
commit | 613d4bd5d56d086ae0fc80746aa111c1ae6b7d2c (patch) | |
tree | 9fb246dccb008b3411c272d6b33677cc4c22a52e /src/bytes.rs | |
parent | dc9c8e304e60b6038e0df4bfd7abfdc145251310 (diff) | |
download | bytes-613d4bd5d56d086ae0fc80746aa111c1ae6b7d2c.tar.gz bytes-613d4bd5d56d086ae0fc80746aa111c1ae6b7d2c.tar.zst bytes-613d4bd5d56d086ae0fc80746aa111c1ae6b7d2c.zip |
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.
Diffstat (limited to 'src/bytes.rs')
-rw-r--r-- | src/bytes.rs | 5 |
1 files changed, 3 insertions, 2 deletions
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) } } |