Skip to content

Commit f97e41a

Browse files
committed
Merge #398: Implement LowerHex and Display for Message
a209836 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 a209836 Tree-SHA512: 64eeafc57ea2814108228d8427cd650076eb3cbb85ae14a7c5a6f39f5e20ca9b83b4ccc27c201668fd57a34fde0a37be4098aa5c602208a81a2018293b40b64d
2 parents bc278fa + a209836 commit f97e41a

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
@@ -324,6 +324,21 @@ impl<T: ThirtyTwoByteHash> From<T> for Message {
324324
}
325325
}
326326

327+
impl fmt::LowerHex for Message {
328+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
329+
for byte in self.0.iter() {
330+
write!(f, "{:02x}", byte)?;
331+
}
332+
Ok(())
333+
}
334+
}
335+
336+
impl fmt::Display for Message {
337+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
338+
fmt::LowerHex::fmt(self, f)
339+
}
340+
}
341+
327342
/// An ECDSA error
328343
#[derive(Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Debug)]
329344
pub enum Error {

0 commit comments

Comments
 (0)