From e9fd7b44ef807b5357c3e8406cbdd033860f2ab9 Mon Sep 17 00:00:00 2001 From: "Martin Taillefer (from Dev Box)" Date: Sat, 27 Jul 2024 05:50:24 -0700 Subject: [PATCH] Implement Clone and Debug for HashTable's Iter struct --- src/table.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/table.rs b/src/table.rs index 421f52ca3..2d1199e66 100644 --- a/src/table.rs +++ b/src/table.rs @@ -1969,6 +1969,23 @@ impl ExactSizeIterator for Iter<'_, T> { impl FusedIterator for Iter<'_, T> {} +// FIXME(#26925) Remove in favor of `#[derive(Clone)]` +impl<'a, T> Clone for Iter<'a, T> { + #[cfg_attr(feature = "inline-more", inline)] + fn clone(&self) -> Iter<'a, T> { + Iter { + inner: self.inner.clone(), + marker: PhantomData, + } + } +} + +impl fmt::Debug for Iter<'_, T> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_list().entries(self.clone()).finish() + } +} + /// A mutable iterator over the entries of a `HashTable` in arbitrary order. /// The iterator element type is `&'a mut T`. ///