Implement LowerHex and Display for Message

Implement `fmt::LowerHex` for `Message`. Implement `Display` by calling
`LowerHex`.

Resolves: #251
This commit is contained in:
Tobin Harding 2022-02-09 09:22:07 +00:00
parent ecb62612b5
commit a209836a99
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
1 changed files with 15 additions and 0 deletions

View File

@ -308,6 +308,21 @@ impl<T: ThirtyTwoByteHash> From<T> for Message {
}
}
impl fmt::LowerHex for Message {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
for byte in self.0.iter() {
write!(f, "{:02x}", byte)?;
}
Ok(())
}
}
impl fmt::Display for Message {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::LowerHex::fmt(self, f)
}
}
/// An ECDSA error
#[derive(Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Debug)]
pub enum Error {