diff --git a/src/bundle.rs b/src/bundle.rs index 2218d313..73e9fc67 100644 --- a/src/bundle.rs +++ b/src/bundle.rs @@ -237,7 +237,7 @@ pub trait Authorization: fmt::Debug { } /// A bundle of actions to be applied to the ledger. -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct Bundle { /// The list of actions that make up this bundle. actions: NonEmpty>, @@ -253,6 +253,26 @@ pub struct Bundle { authorization: T, } +impl fmt::Debug for Bundle { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + /// Helper struct for debug-printing actions without exposing `NonEmpty`. + struct Actions<'a, T>(&'a NonEmpty>); + impl<'a, T: fmt::Debug> fmt::Debug for Actions<'a, T> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_list().entries(self.0.iter()).finish() + } + } + + f.debug_struct("Bundle") + .field("actions", &Actions(&self.actions)) + .field("flags", &self.flags) + .field("value_balance", &self.value_balance) + .field("anchor", &self.anchor) + .field("authorization", &self.authorization) + .finish() + } +} + impl Bundle { /// Constructs a `Bundle` from its constituent parts. pub fn from_parts(