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

Commit

Permalink
Impl Debug and Display for Ss58AddressFormat when compiled with std (#…
Browse files Browse the repository at this point in the history
…6327)

* Initial commit

Forked at: 606c56d
Parent branch: origin/master

* Impl Debug and Display for Ss58AddressFormat when compiled with std

Fixes #6289

* Use write! instead of writeln!
  • Loading branch information
cecton authored Jun 11, 2020
1 parent 164fb3b commit 99708c0
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions primitives/core/src/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,12 +357,20 @@ macro_rules! ss58_address_format {
( $( $identifier:tt => ($number:expr, $name:expr, $desc:tt) )* ) => (
/// A known address (sub)format/network ID for SS58.
#[derive(Copy, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "std", derive(Debug))]
pub enum Ss58AddressFormat {
$(#[doc = $desc] $identifier),*,
/// Use a manually provided numeric value.
Custom(u8),
}

#[cfg(feature = "std")]
impl std::fmt::Display for Ss58AddressFormat {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{:?}", self)
}
}

static ALL_SS58_ADDRESS_FORMATS: [Ss58AddressFormat; 0 $(+ { let _ = $number; 1})*] = [
$(Ss58AddressFormat::$identifier),*,
];
Expand Down

0 comments on commit 99708c0

Please sign in to comment.