Skip to content

Commit

Permalink
Improve debug implementation of Id types
Browse files Browse the repository at this point in the history
  • Loading branch information
mendess committed Sep 26, 2023
1 parent efb6911 commit 2cad5b8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion daphne/src/messages/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const EXTENSION_TASKPROV: u16 = 0xff00;
macro_rules! id_struct {
($sname:ident, $len:expr, $doc:expr) => {
#[doc=$doc]
#[derive(Clone, Debug, Default, Deserialize, Hash, PartialEq, Eq, Serialize)]
#[derive(Clone, Default, Deserialize, Hash, PartialEq, Eq, Serialize)]
pub struct $sname(#[serde(with = "hex")] pub [u8; $len]);

impl $sname {
Expand Down Expand Up @@ -84,6 +84,12 @@ macro_rules! id_struct {
write!(f, "{}", self.to_hex())
}
}

impl fmt::Debug for $sname {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}({})", ::std::stringify!($sname), self.to_hex())
}
}
};
}

Expand Down

0 comments on commit 2cad5b8

Please sign in to comment.