Skip to content

Commit

Permalink
Mention for in the section on loops
Browse files Browse the repository at this point in the history
The "4.3 Loops" section only describes `while` and `loop`. We then see `for`
used in a code sample at the end of the "13. Vectors and strings" section,
but it's explained for the first time only in the next section --
"14. Closures".

It is worth mentioning it in "4.3 Loops".
  • Loading branch information
alco committed Jun 8, 2013
1 parent b8cf2f8 commit 83b68a2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions doc/tutorial.md
Expand Up @@ -569,8 +569,10 @@ loop {
This code prints out a weird sequence of numbers and stops as soon as
it finds one that can be divided by five.
For more involved iteration, such as enumerating the elements of a
collection, Rust uses [higher-order functions](#closures).
Rust also has a `for` construct. It's different from C's `for` and it works
best when iterating over collections. See the section on [closures](#closures)
to find out how to use `for` and higher-order functions for enumerating
elements of a collection.
# Data structures
Expand Down Expand Up @@ -1393,6 +1395,7 @@ assert!(crayons.len() == 3);
assert!(!crayons.is_empty());
// Iterate over a vector, obtaining a pointer to each element
// (`for` is explained in the next section)
for crayons.each |crayon| {
let delicious_crayon_wax = unwrap_crayon(*crayon);
eat_crayon_wax(delicious_crayon_wax);
Expand Down

5 comments on commit 83b68a2

@bors
Copy link
Contributor

@bors bors commented on 83b68a2 Jun 8, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 83b68a2 Jun 8, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging alco/rust/tutorial-for-loop = 83b68a2 into auto

@bors
Copy link
Contributor

@bors bors commented on 83b68a2 Jun 8, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alco/rust/tutorial-for-loop = 83b68a2 merged ok, testing candidate = 9b0986a

@bors
Copy link
Contributor

@bors bors commented on 83b68a2 Jun 8, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 83b68a2 Jun 8, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding incoming to auto = 9b0986a

Please sign in to comment.