Skip to content

Commit

Permalink
ExactSizeIterator for Tuples
Browse files Browse the repository at this point in the history
Only when `I` is exact itself.
Note that in this case, `add_then_div` won't ever return `None` since what is in the buffer was previously in `iter` so `n+a` is less or equal to the iterator length.
  • Loading branch information
Philippe-Cholet committed Sep 27, 2023
1 parent 9f20d49 commit 3667735
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/tuple_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@ fn add_then_div(n: usize, a: usize, d: usize) -> Option<usize> {
(n / d).checked_add(a / d)?.checked_add((n % d + a % d) / d)
}

impl<I, T> ExactSizeIterator for Tuples<I, T>
where
I: ExactSizeIterator<Item = T::Item>,
T: HomogeneousTuple,
{
}

impl<I, T> Tuples<I, T>
where
I: Iterator<Item = T::Item>,
Expand Down

0 comments on commit 3667735

Please sign in to comment.