Closed
Description
In past step_by() needed an argument of the same type of the range:
#![feature(iterator_step_by)]
fn main() {
for i in (1u32 .. 10u32).step_by(2u32) {
println!("{}", i);
}
}
But now it gives an error and asks for an usize:
error[E0308]: mismatched types
--> ...\test.rs:3:38
|
3 | for i in (1u32 .. 10u32).step_by(2u32) {
| ^^^^ expected usize, found u32
Is this desired (and I have to change all my Nightly code)?
This is especially bad when I've used negative step values:
(a - 2 .. 1).step_by(-2)
Now you need to write something like:
(2 + a % 2 .. a - 1).rev().step_by(2)
See also #43012