Skip to content

Commit e71a1fb

Browse files
committed
Add exhaust which simply exhausts the iterator
This is useful for iterators which are simply used for their side effects. The new function is added to make intent clearer for places where you'd previously call `count` or similar to exhaust the iterator.
1 parent 9144f63 commit e71a1fb

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,6 +1522,13 @@ pub trait Itertools : Iterator {
15221522
{
15231523
minmax::minmax_impl(self, f, |_, _, xk, yk| xk < yk, |_, _, xk, yk| xk > yk)
15241524
}
1525+
1526+
/// Exhaust the iterator by repeatedly calling `next()`.
1527+
fn exhaust(self)
1528+
where Self: Sized,
1529+
{
1530+
self.count();
1531+
}
15251532
}
15261533

15271534
impl<T: ?Sized> Itertools for T where T: Iterator { }

0 commit comments

Comments
 (0)