You've already forked comprehensive-rust
mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-06-16 06:10:26 +02:00
396 B
396 B
for
The for
loop iterates over
ranges of values:
fn main() {
for x in 1..5 {
println!("x: {x}");
}
}
- We will discuss iteration later; for now, just stick to range expressions.
- Note that the
for
loop only iterates to4
. Show the1..=5
syntax for an inclusive range.