Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redesign the std::iter::Step trait, tweak related iterator impls for ranges #43127

Closed
wants to merge 11 commits into from
Closed
Prev Previous commit
Next Next commit
Tighter size_hint lower bound for ranges larger than usize
  • Loading branch information
SimonSapin committed Jul 24, 2017
commit b270e7f524c7a2ff41beb3bf93edf23e2ffc7e22
4 changes: 2 additions & 2 deletions src/libcore/iter/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ impl<A: Step> Iterator for ops::Range<A> {
// NOTE: the safety of `unsafe impl TrustedLen` depends on this being correct!
match Step::steps_between(&self.start, &self.end) {
Some(hint) => (hint, Some(hint)),
None => (0, None)
None => (usize::MAX, None)
}
}

Expand Down Expand Up @@ -410,7 +410,7 @@ impl<A: Step> Iterator for ops::RangeInclusive<A> {

match Step::steps_between(&self.start, &self.end) {
Some(hint) => (hint.saturating_add(1), hint.checked_add(1)),
None => (0, None),
None => (usize::MAX, None),
}
}

Expand Down