diff --git a/src/common.rs b/src/common.rs index 21af2700159a7b95ee62aa762d24275b6aadf333..2c816e862dd1bf006eccbb36e16c9d34dfdb78c7 100644 --- a/src/common.rs +++ b/src/common.rs @@ -87,6 +87,7 @@ pub(crate) enum SyncBlocker { CouldntCheckFiring(PortId), PutMsg(PortId, Payload), } +pub(crate) struct DenseDebugHex<'a>(pub &'a [u8]); ///////////////////// IMPL ///////////////////// impl U32Stream { @@ -176,7 +177,7 @@ impl Debug for ProtoComponentId { } impl Debug for Payload { fn fmt(&self, f: &mut Formatter) -> std::fmt::Result { - write!(f, "Payload{:x?}", self.as_slice()) + write!(f, "Payload[{:?}]", DenseDebugHex(self.as_slice())) } } impl std::ops::Not for Polarity { @@ -189,3 +190,11 @@ impl std::ops::Not for Polarity { } } } +impl Debug for DenseDebugHex<'_> { + fn fmt(&self, f: &mut Formatter) -> std::fmt::Result { + for b in self.0 { + write!(f, "{:02X?}", b)?; + } + Ok(()) + } +}