Ranges with a custom step

Rust Range structs and anything that implements the Iterator trait have a step_by method that allows you to iterate by a given number:

for i in (1..10).step_by(2) {
    println!("i: {}", i);
}

source

View on Github