Skip to content

Commit

Permalink
feat: Debug output with binary fmt as well
Browse files Browse the repository at this point in the history
  • Loading branch information
maqi committed Apr 19, 2021
1 parent 12dd571 commit 1382403
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,11 @@ impl XorName {

impl fmt::Debug for XorName {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
write!(formatter, "{}", self)
write!(
formatter,
"{:02x}{:02x}{:02x}({:08b})..",
self[0], self[1], self[2], self
)
}
}

Expand Down Expand Up @@ -378,12 +382,12 @@ mod tests {
#[test]
fn format_debug() {
assert_eq!(
&format!(8, "{:?}", xor_name!(0x01, 0x23, 0x45, 0x67)),
"012345.."
&format!(18, "{:?}", xor_name!(0x01, 0x23, 0x45, 0x67)),
"012345(00000001).."
);
assert_eq!(
&format!(8, "{:?}", xor_name!(0x89, 0xab, 0xcd, 0xdf)),
"89abcd.."
&format!(18, "{:?}", xor_name!(0x89, 0xab, 0xcd, 0xdf)),
"89abcd(10001001).."
);
}

Expand Down

0 comments on commit 1382403

Please sign in to comment.