From 3fcd703607cd92f95d28261da669b95110fece4e Mon Sep 17 00:00:00 2001 From: Christoph Herzog Date: Wed, 7 Aug 2024 07:11:57 +0200 Subject: [PATCH] chore: Use hex encoding for Sha256Hash debug impl This makes debug output easier to work with. --- lib/config/src/hash.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/config/src/hash.rs b/lib/config/src/hash.rs index a7475ae3fd1..880edf0d071 100644 --- a/lib/config/src/hash.rs +++ b/lib/config/src/hash.rs @@ -1,5 +1,5 @@ /// Sha256 hash, represented as bytes. -#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct Sha256Hash(pub [u8; 32]); impl Sha256Hash { @@ -33,6 +33,12 @@ impl std::str::FromStr for Sha256Hash { } } +impl std::fmt::Debug for Sha256Hash { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "Sha256({})", hex::encode(self.0)) + } +} + impl std::fmt::Display for Sha256Hash { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{}", hex::encode(self.0))