Skip to content

Commit 866c8cc

Browse files
committed
Implement FusedIterator and size_hint for DrainFilter
1 parent 17e6ecc commit 866c8cc

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
@@ -1390,8 +1390,15 @@ where
13901390
fn next(&mut self) -> Option<Self::Item> {
13911391
self.inner.next(&mut self.f)
13921392
}
1393+
1394+
#[inline]
1395+
fn size_hint(&self) -> (usize, Option<usize>) {
1396+
(0, self.inner.iter.size_hint().1)
1397+
}
13931398
}
13941399

1400+
impl<K, V, F> FusedIterator for DrainFilter<'_, K, V, F> where F: FnMut(&K, &mut V) -> bool {}
1401+
13951402
/// Portions of `DrainFilter` shared with `set::DrainFilter`
13961403
pub(super) struct DrainFilterInner<'a, K, V> {
13971404
pub iter: RawIter<(K, V)>,

src/set.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1462,8 +1462,15 @@ where
14621462
let (k, _) = self.inner.next(&mut |k, _| f(k))?;
14631463
Some(k)
14641464
}
1465+
1466+
#[inline]
1467+
fn size_hint(&self) -> (usize, Option<usize>) {
1468+
(0, self.inner.iter.size_hint().1)
1469+
}
14651470
}
14661471

1472+
impl<K, F> FusedIterator for DrainFilter<'_, K, F> where F: FnMut(&K) -> bool {}
1473+
14671474
impl<T, S> Clone for Intersection<'_, T, S> {
14681475
#[cfg_attr(feature = "inline-more", inline)]
14691476
fn clone(&self) -> Self {

0 commit comments

Comments
 (0)