Closed
Description
Repro: https://is.gd/nFIian (tried 2017-04-21)
#![feature(step_by)]
#![feature(inclusive_range_syntax)]
fn main() {
let i = (0...10).step_by(3);
assert!(i.size_hint().0 <= i.count());
}
Looks like the implementation is adding one to the Range (exclusive) lower bound, which is incorrect when the size of the base range isn't a multiple of the step.
Thoughts on whether it'd be a better fix to just not add one (correct, but a less-helpful hint) or to add one to end before calling Step::steps_between
(better hint, more math and more overflow cases)?
Activity
..=
inclusive ranges (RFC #1192) -- originally...
#28237Remove deprecated `Range::step_by` (use `Iterator::step_by` instead)
Range::step_by
(useIterator::step_by
instead) #42110DeprecatedStepBy<A, RangeInclusive<A>>
gives bad size hints #42514cuviper commentedon Jun 9, 2017
From what I saw on #42514, the upper bound can also be one too high. That's less problematic, I suppose, although the proposal to "just not add one" should not apply to the upper bound since then it would be too low in some cases.
Of course, it's a bit moot since this is now deprecated and expected to be removed soon. :)
step_by
#43012Auto merge of #43012 - scottmcm:delete-range-step-by, r=alexcrichton