Range with step is useful. If we implement Iterator for tuple (A, Range) or (A, RangeInclusive), we can get a syntax that matches the math syntax without break change to current syntax.
For example, if we implement Iterator for these tuples, we can:
for i in (0,2..10) { // because it is actually a tuple, braces are necessary.
println!("{}", i);
}
// print: 0, 2, 4, 6, 8
// and
for i in (0,2..=10) { // we can also use equal to express inclusive range.
println!("{}", i);
}
// print: 0, 2, 4, 6, 8, 10
// and we can create reverse range
for i in (5, 4..=0) { // we can also use equal to express inclusive range.
println!("{}", i);
}
// print: 5, 4, 3, 2, 1, 0
// the implementation can be like this:
(0,2..10).next() == Some((2,4..10))
(5,4..=0).next() == Some((4,3..=0))
Apart from for-loops, if you had used numpy, you may know range with step is useful in slicing matrix in axises, or reversing a axis. This syntax is helpful for develop a matrix library.
Finally, it can be used for float loops like (1.0, 1.1..2.0). However, it may has numerical issues about float adding and subbing. (although no issue was found on my personal testing.)
This is just an idea, but I hope it can be useful.