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) } }