Skip to content

Commit 240b6ab

Browse files
committed
---
yaml --- r: 63097 b: refs/heads/snap-stage3 c: 93b2ddf h: refs/heads/master i: 63095: ff536f8 v: v3
1 parent aa44009 commit 240b6ab

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 9b0986acf4397207a29ee6f94433efd5b4b5bc79
4+
refs/heads/snap-stage3: 93b2ddfc88f581a1155236c9ac79983f72b0ff46
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/doc/tutorial.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -569,10 +569,8 @@ loop {
569569
This code prints out a weird sequence of numbers and stops as soon as
570570
it finds one that can be divided by five.
571571

572-
Rust also has a `for` construct. It's different from C's `for` and it works
573-
best when iterating over collections. See the section on [closures](#closures)
574-
to find out how to use `for` and higher-order functions for enumerating
575-
elements of a collection.
572+
For more involved iteration, such as enumerating the elements of a
573+
collection, Rust uses [higher-order functions](#closures).
576574

577575
# Data structures
578576

@@ -1395,7 +1393,6 @@ assert!(crayons.len() == 3);
13951393
assert!(!crayons.is_empty());
13961394
13971395
// Iterate over a vector, obtaining a pointer to each element
1398-
// (`for` is explained in the next section)
13991396
for crayons.each |crayon| {
14001397
let delicious_crayon_wax = unwrap_crayon(*crayon);
14011398
eat_crayon_wax(delicious_crayon_wax);
@@ -1442,10 +1439,15 @@ call_closure_with_ten(closure);
14421439
~~~~
14431440

14441441
Closures begin with the argument list between vertical bars and are followed by
1445-
a single expression. The types of the arguments are generally omitted,
1446-
as is the return type, because the compiler can almost always infer
1447-
them. In the rare case where the compiler needs assistance, though, the
1448-
arguments and return types may be annotated.
1442+
a single expression. Remember that a block, `{ <expr1>; <expr2>; ... }`, is
1443+
considered a single expression: it evaluates to the result of the last
1444+
expression it contains if that expression is not followed by a semicolon,
1445+
otherwise the block evaluates to `()`.
1446+
1447+
The types of the arguments are generally omitted, as is the return type,
1448+
because the compiler can almost always infer them. In the rare case where the
1449+
compiler needs assistance, though, the arguments and return types may be
1450+
annotated.
14491451

14501452
~~~~
14511453
let square = |x: int| -> uint { x * x as uint };

0 commit comments

Comments
 (0)