From 2cae33cf6e22aaa6308a8289b8859f7334499618 Mon Sep 17 00:00:00 2001 From: Cecile Tonglet Date: Thu, 11 Jun 2020 12:16:17 +0200 Subject: [PATCH] Impl Debug and Display for Ss58AddressFormat when compiled with std (#6327) * Initial commit Forked at: f5caf030aa522cf63506b7ea37248a162e1b6052 Parent branch: origin/master * Impl Debug and Display for Ss58AddressFormat when compiled with std Fixes #6289 * Use write! instead of writeln! --- substrate/primitives/core/src/crypto.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/substrate/primitives/core/src/crypto.rs b/substrate/primitives/core/src/crypto.rs index 73134dcbfa..b92eb8eab0 100644 --- a/substrate/primitives/core/src/crypto.rs +++ b/substrate/primitives/core/src/crypto.rs @@ -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),*, ];