Skip to content

Commit a209836

Browse files
committed
Implement LowerHex and Display for Message
Implement `fmt::LowerHex` for `Message`. Implement `Display` by calling `LowerHex`. Resolves: #251
1 parent ecb6261 commit a209836

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/lib.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,21 @@ impl<T: ThirtyTwoByteHash> From<T> for Message {
308308
}
309309
}
310310

311+
impl fmt::LowerHex for Message {
312+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
313+
for byte in self.0.iter() {
314+
write!(f, "{:02x}", byte)?;
315+
}
316+
Ok(())
317+
}
318+
}
319+
320+
impl fmt::Display for Message {
321+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
322+
fmt::LowerHex::fmt(self, f)
323+
}
324+
}
325+
311326
/// An ECDSA error
312327
#[derive(Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Debug)]
313328
pub enum Error {

0 commit comments

Comments
 (0)