Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Make Ss58AddressFormat display less expressive (#6941)
Browse files Browse the repository at this point in the history
Instead of using the `Debug` implementation inside the `Display`
implementation this pr changes it to display only the name of the format.
  • Loading branch information
bkchr authored Aug 23, 2020
1 parent ddf333c commit 72102d2
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions primitives/core/src/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,13 @@ macro_rules! ss58_address_format {
#[cfg(feature = "std")]
impl std::fmt::Display for Ss58AddressFormat {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{:?}", self)
match self {
$(
Ss58AddressFormat::$identifier => write!(f, "{}", $name),
)*
Ss58AddressFormat::Custom(x) => write!(f, "{}", x),
}

}
}

Expand Down Expand Up @@ -419,10 +425,7 @@ macro_rules! ss58_address_format {
#[cfg(feature = "std")]
impl From<Ss58AddressFormat> for String {
fn from(x: Ss58AddressFormat) -> String {
match x {
$(Ss58AddressFormat::$identifier => $name.into()),*,
Ss58AddressFormat::Custom(x) => x.to_string(),
}
x.to_string()
}
}
)
Expand Down

0 comments on commit 72102d2

Please sign in to comment.