Skip to content

Commit

Permalink
Merge pull request #66 from Ten0/fix_missing_double_ended_iter_spec
Browse files Browse the repository at this point in the history
Add missing specializations on `Iterator` impl
  • Loading branch information
cuviper authored Jun 28, 2022
2 parents 23a36c1 + ea284e2 commit fbbadd0
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -940,13 +940,28 @@ where
fn next_back(&mut self) -> Option<Self::Item> {
for_both!(*self, ref mut inner => inner.next_back())
}

// TODO(MSRV): This was stabilized in Rust 1.37
// fn nth_back(&mut self, n: usize) -> Option<Self::Item> {
// for_both!(*self, ref mut inner => inner.nth_back(n))
// }

fn rfold<Acc, G>(self, init: Acc, f: G) -> Acc
where
G: FnMut(Acc, Self::Item) -> Acc,
{
for_both!(self, inner => inner.rfold(init, f))
}
}

impl<L, R> ExactSizeIterator for Either<L, R>
where
L: ExactSizeIterator,
R: ExactSizeIterator<Item = L::Item>,
{
fn len(&self) -> usize {
for_both!(*self, ref inner => inner.len())
}
}

#[cfg(any(test, feature = "use_std"))]
Expand Down

0 comments on commit fbbadd0

Please sign in to comment.