From cba7243360c4630974c69d3a9fa7b4c6ff8f9105 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Tue, 14 Jun 2022 00:11:46 +0200 Subject: [PATCH] Properly implement Debug on bounded types --- primitives/runtime/src/bounded/bounded_btree_map.rs | 7 +++---- primitives/runtime/src/bounded/bounded_btree_set.rs | 7 +++---- primitives/runtime/src/bounded/bounded_vec.rs | 2 +- primitives/runtime/src/bounded/weak_bounded_vec.rs | 7 +++---- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/primitives/runtime/src/bounded/bounded_btree_map.rs b/primitives/runtime/src/bounded/bounded_btree_map.rs index b9abf77f175c6..aefd168632a1e 100644 --- a/primitives/runtime/src/bounded/bounded_btree_map.rs +++ b/primitives/runtime/src/bounded/bounded_btree_map.rs @@ -182,13 +182,12 @@ where } } -#[cfg(feature = "std")] -impl std::fmt::Debug for BoundedBTreeMap +impl sp_std::fmt::Debug for BoundedBTreeMap where - BTreeMap: std::fmt::Debug, + BTreeMap: sp_std::fmt::Debug, S: Get, { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + fn fmt(&self, f: &mut sp_std::fmt::Formatter<'_>) -> sp_std::fmt::Result { f.debug_tuple("BoundedBTreeMap").field(&self.0).field(&Self::bound()).finish() } } diff --git a/primitives/runtime/src/bounded/bounded_btree_set.rs b/primitives/runtime/src/bounded/bounded_btree_set.rs index 0f8cc769e47e3..c19d176f11bef 100644 --- a/primitives/runtime/src/bounded/bounded_btree_set.rs +++ b/primitives/runtime/src/bounded/bounded_btree_set.rs @@ -159,13 +159,12 @@ where } } -#[cfg(feature = "std")] -impl std::fmt::Debug for BoundedBTreeSet +impl sp_std::fmt::Debug for BoundedBTreeSet where - BTreeSet: std::fmt::Debug, + BTreeSet: sp_std::fmt::Debug, S: Get, { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + fn fmt(&self, f: &mut sp_std::fmt::Formatter<'_>) -> sp_std::fmt::Result { f.debug_tuple("BoundedBTreeSet").field(&self.0).field(&Self::bound()).finish() } } diff --git a/primitives/runtime/src/bounded/bounded_vec.rs b/primitives/runtime/src/bounded/bounded_vec.rs index 84acddea47cab..555a34819a423 100644 --- a/primitives/runtime/src/bounded/bounded_vec.rs +++ b/primitives/runtime/src/bounded/bounded_vec.rs @@ -598,7 +598,7 @@ impl Default for BoundedVec { impl sp_std::fmt::Debug for BoundedVec where - T: sp_std::fmt::Debug, + Vec: sp_std::fmt::Debug, S: Get, { fn fmt(&self, f: &mut sp_std::fmt::Formatter<'_>) -> sp_std::fmt::Result { diff --git a/primitives/runtime/src/bounded/weak_bounded_vec.rs b/primitives/runtime/src/bounded/weak_bounded_vec.rs index 82bae4118f13e..08460f7096357 100644 --- a/primitives/runtime/src/bounded/weak_bounded_vec.rs +++ b/primitives/runtime/src/bounded/weak_bounded_vec.rs @@ -168,13 +168,12 @@ impl Default for WeakBoundedVec { } } -#[cfg(feature = "std")] -impl std::fmt::Debug for WeakBoundedVec +impl sp_std::fmt::Debug for WeakBoundedVec where - T: std::fmt::Debug, + Vec: sp_std::fmt::Debug, S: Get, { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + fn fmt(&self, f: &mut sp_std::fmt::Formatter<'_>) -> sp_std::fmt::Result { f.debug_tuple("WeakBoundedVec").field(&self.0).field(&Self::bound()).finish() } }