Avatar ·

How to iterate over a range of numbers with a non-standard step in Rust?

Hi everyone! I just started learning Rust and ran into a problem that seems trivial in other languages, but here it has me stumped. I need to iterate over numbers from 0 to 100, but with a step of 3, i.e.: 0, 3, 6, 9, ... 99. In Python I would write `for i in range(0, 100, 3):` and it would work. In Rust I try the standard `for i in 0..100` — this gives a step of 1. If I write `for i in (0..100).step_by(3)`, the compiler gives an error: "no method named `step_by` found for struct `Range`". I googled and found that `step_by` exists, but for some reason it doesn't work for a simple range. I tried importing some traits, but nothing helped. My current code looks like this: ```rust fn main() { for i in 0..100 { println!("{}", i); // This is step 1, but I need step