Skip to content

Commit 2b9cbea

Browse files
committed
impl Debug for Drain
1 parent 7423210 commit 2b9cbea

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/map.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,6 +1122,13 @@ impl<K, V> ExactSizeIterator for Drain<'_, K, V> {
11221122

11231123
impl<K, V> FusedIterator for Drain<'_, K, V> {}
11241124

1125+
impl<K: fmt::Debug, V: fmt::Debug> fmt::Debug for Drain<'_, K, V> {
1126+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1127+
let iter = self.iter.as_slice().iter().map(Bucket::refs);
1128+
f.debug_list().entries(iter).finish()
1129+
}
1130+
}
1131+
11251132
impl<'a, K, V, S> IntoIterator for &'a IndexMap<K, V, S> {
11261133
type Item = (&'a K, &'a V);
11271134
type IntoIter = Iter<'a, K, V>;

src/set.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,13 @@ impl<T> ExactSizeIterator for Drain<'_, T> {
798798

799799
impl<T> FusedIterator for Drain<'_, T> {}
800800

801+
impl<T: fmt::Debug> fmt::Debug for Drain<'_, T> {
802+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
803+
let iter = self.iter.as_slice().iter().map(Bucket::key_ref);
804+
f.debug_list().entries(iter).finish()
805+
}
806+
}
807+
801808
impl<'a, T, S> IntoIterator for &'a IndexSet<T, S> {
802809
type Item = &'a T;
803810
type IntoIter = Iter<'a, T>;

0 commit comments

Comments
 (0)