From c49fc2c723b340420e42000a5ce3e8ce918165e2 Mon Sep 17 00:00:00 2001 From: Colin Snover Date: Sun, 8 Aug 2021 14:02:16 -0500 Subject: [PATCH] Add alternate debug output for listing items in the slab --- src/lib.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index d277547..1fe5032 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1253,10 +1253,14 @@ where T: fmt::Debug, { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { - fmt.debug_struct("Slab") - .field("len", &self.len) - .field("cap", &self.capacity()) - .finish() + if fmt.alternate() { + fmt.debug_map().entries(self.iter()).finish() + } else { + fmt.debug_struct("Slab") + .field("len", &self.len) + .field("cap", &self.capacity()) + .finish() + } } }