Merge rust-bitcoin/rust-secp256k1#398: Implement LowerHex and Display for Message

a209836a99 Implement LowerHex and Display for Message (Tobin Harding)

Pull request description:

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

  Resolves: #251

ACKs for top commit:
  apoelstra:
    ACK a209836a99

Tree-SHA512: 64eeafc57ea2814108228d8427cd650076eb3cbb85ae14a7c5a6f39f5e20ca9b83b4ccc27c201668fd57a34fde0a37be4098aa5c602208a81a2018293b40b64d
This commit is contained in:
Andrew Poelstra 2022-02-09 18:33:30 +00:00
commit f97e41ae21
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
1 changed files with 15 additions and 0 deletions

View File

@ -324,6 +324,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 {