Impl Debug and Display for Ss58AddressFormat when compiled with std (#6327)

* Initial commit

Forked at: f5caf030aa
Parent branch: origin/master

* Impl Debug and Display for Ss58AddressFormat when compiled with std

Fixes #6289

* Use write! instead of writeln!
This commit is contained in:
Cecile Tonglet
2020-06-11 12:16:17 +02:00
committed by GitHub
parent 731e7d77c7
commit 2cae33cf6e
+8
View File
@@ -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),*,
];