Skip to content

Commit

Permalink
chore: Use hex encoding for Sha256Hash debug impl
Browse files Browse the repository at this point in the history
This makes debug output easier to work with.
  • Loading branch information
theduke committed Aug 7, 2024
1 parent f571107 commit 074c4a2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/config/src/hash.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit 074c4a2

Please sign in to comment.