Remove the impl_array_newtype_show macro

Instead, implement Debug in impl_bytes_newtype.
This commit is contained in:
Steven Roose 2020-10-25 17:29:15 +00:00 committed by Sebastian
parent 0ab8823984
commit d527a2c2cf
2 changed files with 6 additions and 13 deletions

View File

@ -95,17 +95,6 @@ macro_rules! impl_array_newtype {
}
}
/// Implements debug formatting for a given wrapper type
macro_rules! impl_array_newtype_show {
($thing:ident) => {
impl ::std::fmt::Debug for $thing {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
write!(f, concat!(stringify!($thing), "({:?})"), &self[..])
}
}
}
}
/// Implements standard indexing methods for a given wrapper type
macro_rules! impl_index_newtype {
($thing:ident, $ty:ty) => {
@ -583,6 +572,12 @@ macro_rules! impl_bytes_newtype {
}
}
impl ::std::fmt::Debug for $t {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
fmt::LowerHex::fmt(self, f)
}
}
impl $crate::hashes::hex::FromHex for $t {
fn from_byte_iter<I>(iter: I) -> Result<Self, $crate::hashes::hex::Error>
where I: ::std::iter::Iterator<Item=Result<u8, $crate::hashes::hex::Error>> +

View File

@ -33,14 +33,12 @@ use util::key::{self, PublicKey, PrivateKey};
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct ChainCode([u8; 32]);
impl_array_newtype!(ChainCode, u8, 32);
impl_array_newtype_show!(ChainCode);
impl_bytes_newtype!(ChainCode, 32);
/// A fingerprint
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Fingerprint([u8; 4]);
impl_array_newtype!(Fingerprint, u8, 4);
impl_array_newtype_show!(Fingerprint);
impl_bytes_newtype!(Fingerprint, 4);
impl Default for Fingerprint {