change `Debug` impl for `Signature` to use `Display`

This commit is contained in:
Andrew Poelstra 2018-10-28 15:11:04 +00:00
parent 30aa3a0c28
commit 68c838f357
1 changed files with 8 additions and 1 deletions

View File

@ -161,9 +161,15 @@ use std::marker::PhantomData;
pub struct RecoveryId(i32); pub struct RecoveryId(i32);
/// An ECDSA signature /// An ECDSA signature
#[derive(Copy, Clone, PartialEq, Eq, Debug)] #[derive(Copy, Clone, PartialEq, Eq)]
pub struct Signature(ffi::Signature); pub struct Signature(ffi::Signature);
impl fmt::Debug for Signature {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Display::fmt(self, f)
}
}
impl fmt::Display for Signature { impl fmt::Display for Signature {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let mut v = [0; 72]; let mut v = [0; 72];
@ -893,6 +899,7 @@ mod tests {
let sig = Signature::from_str(&hex_str).expect("byte str decode"); let sig = Signature::from_str(&hex_str).expect("byte str decode");
assert_eq!(&sig.to_string(), hex_str); assert_eq!(&sig.to_string(), hex_str);
assert_eq!(&format!("{:?}", sig), hex_str);
assert!(Signature::from_str( assert!(Signature::from_str(
"3046022100839c1fbc5304de944f697c9f4b1d01d1faeba32d751c0f7acb21ac8a0f436a\ "3046022100839c1fbc5304de944f697c9f4b1d01d1faeba32d751c0f7acb21ac8a0f436a\