From c06346cc4bed388f112ac80b6daa1fb90a700808 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Tue, 6 Feb 2018 16:19:42 +0100 Subject: [PATCH] Add 0x when printing hex values. --- src/hash.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/hash.rs b/src/hash.rs index 58c561a..5e4696a 100644 --- a/src/hash.rs +++ b/src/hash.rs @@ -119,15 +119,14 @@ macro_rules! construct_hash { impl ::core::fmt::Debug for $from { fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - for i in &self.0[..] { - write!(f, "{:02x}", i)?; - } - Ok(()) + write!(f, "0x")?; + ::core::fmt::LowerHex::fmt(self, f) } } impl ::core::fmt::Display for $from { fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { + write!(f, "0x")?; for i in &self.0[0..2] { write!(f, "{:02x}", i)?; } @@ -141,7 +140,10 @@ macro_rules! construct_hash { impl ::core::fmt::LowerHex for $from { fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - ::core::fmt::Debug::fmt(self, f) + for i in &self.0[..] { + write!(f, "{:02x}", i)?; + } + Ok(()) } }