Manually implement Debug for SerializedSignature
Currently we have an implementation of `Debug` (also used by `Display`) for `Signature` that first converts the sig to a `SerializedSignature` then prints it as hex. We would like to have an implementation of `Debug` for `SerializedSignature`, this cannot be derived because of the `data: [u8; field]`. We can manually implement `Debug` for `SerializedSignature` exactly as it is currently done for `Signature` and call this new implementation from `Signature::fmt()`. This code path is already tested in `lib.rs` in the test function `signature_display`.
This commit is contained in:
parent
26921a31b8
commit
69f44d9301
|
@ -32,7 +32,19 @@ impl fmt::Debug for Signature {
|
|||
impl fmt::Display for Signature {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
let sig = self.serialize_der();
|
||||
for v in sig.iter() {
|
||||
sig.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for SerializedSignature {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fmt::Display::fmt(self, f)
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for SerializedSignature {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
for v in self.data.iter().take(self.len) {
|
||||
write!(f, "{:02x}", v)?;
|
||||
}
|
||||
Ok(())
|
||||
|
|
Loading…
Reference in New Issue