Skip to content

Commit 3a44f89

Browse files
committed
impl ExactSizeIterator for Drain
1 parent 306d6b1 commit 3a44f89

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/map.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,6 +1098,12 @@ impl<K, V> DoubleEndedIterator for Drain<'_, K, V> {
10981098
double_ended_iterator_methods!(Bucket::key_value);
10991099
}
11001100

1101+
impl<K, V> ExactSizeIterator for Drain<'_, K, V> {
1102+
fn len(&self) -> usize {
1103+
self.iter.len()
1104+
}
1105+
}
1106+
11011107
impl<'a, K, V, S> IntoIterator for &'a IndexMap<K, V, S> {
11021108
type Item = (&'a K, &'a V);
11031109
type IntoIter = Iter<'a, K, V>;

src/set.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,12 @@ impl<T> DoubleEndedIterator for Drain<'_, T> {
786786
double_ended_iterator_methods!(Bucket::key);
787787
}
788788

789+
impl<T> ExactSizeIterator for Drain<'_, T> {
790+
fn len(&self) -> usize {
791+
self.iter.len()
792+
}
793+
}
794+
789795
impl<'a, T, S> IntoIterator for &'a IndexSet<T, S> {
790796
type Item = &'a T;
791797
type IntoIter = Iter<'a, T>;

0 commit comments

Comments
 (0)