diff --git a/consensus/types/src/runtime_fixed_vector.rs b/consensus/types/src/runtime_fixed_vector.rs index 2b08b7bf70..f562322a3d 100644 --- a/consensus/types/src/runtime_fixed_vector.rs +++ b/consensus/types/src/runtime_fixed_vector.rs @@ -2,12 +2,21 @@ //! //! The length of the list cannot be changed once it is set. -#[derive(Clone, Debug)] +use std::fmt; +use std::fmt::Debug; + +#[derive(Clone)] pub struct RuntimeFixedVector { vec: Vec, len: usize, } +impl Debug for RuntimeFixedVector { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{:?} (len={})", self.vec, self.len) + } +} + impl RuntimeFixedVector { pub fn new(vec: Vec) -> Self { let len = vec.len(); diff --git a/consensus/types/src/runtime_var_list.rs b/consensus/types/src/runtime_var_list.rs index dcb98538b7..d57c65b1b7 100644 --- a/consensus/types/src/runtime_var_list.rs +++ b/consensus/types/src/runtime_var_list.rs @@ -4,6 +4,8 @@ use serde::de::Error as DeError; use serde::{Deserialize, Deserializer, Serialize}; use ssz::Decode; use ssz_types::Error; +use std::fmt; +use std::fmt::Debug; use std::ops::{Deref, Index, IndexMut}; use std::slice::SliceIndex; use tree_hash::{Hash256, MerkleHasher, PackedEncoding, TreeHash, TreeHashType}; @@ -42,7 +44,7 @@ use tree_hash::{Hash256, MerkleHasher, PackedEncoding, TreeHash, TreeHashType}; /// assert!(long.push(6).is_err()); /// /// ``` -#[derive(Debug, Clone, Serialize, Deserialize, Derivative)] +#[derive(Clone, Serialize, Deserialize, Derivative)] #[derivative(PartialEq, Eq, Hash(bound = "T: std::hash::Hash"))] #[serde(transparent)] pub struct RuntimeVariableList { @@ -51,6 +53,12 @@ pub struct RuntimeVariableList { max_len: usize, } +impl Debug for RuntimeVariableList { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{:?} (max_len={})", self.vec, self.max_len) + } +} + impl RuntimeVariableList { /// Returns `Ok` if the given `vec` equals the fixed length of `Self`. Otherwise returns /// `Err(OutOfBounds { .. })`.