diff --git a/src/arena.rs b/src/arena.rs index 347dfe206..9af0808e4 100644 --- a/src/arena.rs +++ b/src/arena.rs @@ -45,7 +45,7 @@ impl Ord for Handle { } impl fmt::Debug for Handle { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - write!(formatter, "Handle({})", self.index) + write!(formatter, "[{}]", self.index) } } impl hash::Hash for Handle { @@ -81,7 +81,6 @@ impl Handle { /// Adding new items to the arena produces a strongly-typed [`Handle`]. /// The arena can be indexed using the given handle to obtain /// a reference to the stored item. -#[derive(Debug)] #[cfg_attr(feature = "serialize", derive(serde::Serialize))] #[cfg_attr(feature = "deserialize", derive(serde::Deserialize))] #[cfg_attr( @@ -99,6 +98,11 @@ impl Default for Arena { Self::new() } } +impl fmt::Debug for Arena { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_map().entries(self.iter()).finish() + } +} impl Arena { /// Create a new arena with no initial capacity allocated.