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

Commit

Permalink
Properly implement Debug on bounded types (#11659)
Browse files Browse the repository at this point in the history
  • Loading branch information
KiChjang authored Jun 14, 2022
1 parent 323eecd commit 9a140a6
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
7 changes: 3 additions & 4 deletions primitives/runtime/src/bounded/bounded_btree_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,12 @@ where
}
}

#[cfg(feature = "std")]
impl<K, V, S> std::fmt::Debug for BoundedBTreeMap<K, V, S>
impl<K, V, S> sp_std::fmt::Debug for BoundedBTreeMap<K, V, S>
where
BTreeMap<K, V>: std::fmt::Debug,
BTreeMap<K, V>: sp_std::fmt::Debug,
S: Get<u32>,
{
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()
}
}
Expand Down
7 changes: 3 additions & 4 deletions primitives/runtime/src/bounded/bounded_btree_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,12 @@ where
}
}

#[cfg(feature = "std")]
impl<T, S> std::fmt::Debug for BoundedBTreeSet<T, S>
impl<T, S> sp_std::fmt::Debug for BoundedBTreeSet<T, S>
where
BTreeSet<T>: std::fmt::Debug,
BTreeSet<T>: sp_std::fmt::Debug,
S: Get<u32>,
{
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()
}
}
Expand Down
2 changes: 1 addition & 1 deletion primitives/runtime/src/bounded/bounded_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ impl<T, S> Default for BoundedVec<T, S> {

impl<T, S> sp_std::fmt::Debug for BoundedVec<T, S>
where
T: sp_std::fmt::Debug,
Vec<T>: sp_std::fmt::Debug,
S: Get<u32>,
{
fn fmt(&self, f: &mut sp_std::fmt::Formatter<'_>) -> sp_std::fmt::Result {
Expand Down
7 changes: 3 additions & 4 deletions primitives/runtime/src/bounded/weak_bounded_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,12 @@ impl<T, S> Default for WeakBoundedVec<T, S> {
}
}

#[cfg(feature = "std")]
impl<T, S> std::fmt::Debug for WeakBoundedVec<T, S>
impl<T, S> sp_std::fmt::Debug for WeakBoundedVec<T, S>
where
T: std::fmt::Debug,
Vec<T>: sp_std::fmt::Debug,
S: Get<u32>,
{
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()
}
}
Expand Down

0 comments on commit 9a140a6

Please sign in to comment.