Skip to content

Latest commit

 

History

History
12 lines (9 loc) · 322 Bytes

ranges-with-a-custom-step.md

File metadata and controls

12 lines (9 loc) · 322 Bytes

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