From 94974ec19a1fd24d5a44050b295694116d601d77 Mon Sep 17 00:00:00 2001 From: Eugene P Date: Thu, 10 Jan 2019 13:01:45 +0300 Subject: [PATCH] Strip hash in fmt::Debug and use fmt::Debug for fmt::Display --- core/src/core/hash.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/core/src/core/hash.rs b/core/src/core/hash.rs index 8c38f9d7..37894043 100644 --- a/core/src/core/hash.rs +++ b/core/src/core/hash.rs @@ -38,16 +38,16 @@ pub struct Hash([u8; 32]); impl fmt::Debug for Hash { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{}", self.to_hex()) + let hash_hex = self.to_hex(); + const NUM_SHOW: usize = 12; + + write!(f, "{}...", &hash_hex[..NUM_SHOW]) } } impl fmt::Display for Hash { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let hash_hex = self.to_hex(); - const NUM_SHOW: usize = 12; - - write!(f, "{}...", &hash_hex[..NUM_SHOW]) + fmt::Debug::fmt(self, f) } }