Skip to content

Commit fbadb36

Browse files
committed
Document for-loop in tutorial section on loops
1 parent 838c62b commit fbadb36

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/doc/tutorial.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,18 @@ loop {
582582
This code prints out a weird sequence of numbers and stops as soon as
583583
it finds one that can be divided by five.
584584

585+
There is also a for-loop that can be used to iterate over a range of numbers
586+
(or, more generally, anything implementing the `Iterator` trait):
587+
588+
~~~~
589+
for n in range(0, 5) {
590+
println!("{}", n);
591+
}
592+
~~~~
593+
594+
The snippet above prints integer numbers under 5 starting at 0.
595+
596+
585597
# Data structures
586598

587599
## Structs

0 commit comments

Comments
 (0)