Skip to content

Commit def1b2f

Browse files
committed
---
yaml --- r: 24127 b: refs/heads/master c: ba8750a h: refs/heads/master i: 24125: 54483ab 24123: d72d1ee 24119: d2f6b04 24111: 95bbb3a 24095: d27837f 24063: fff145a v: v3
1 parent b0ee22a commit def1b2f

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: a8406e3d00ca791317f85d369e6157e4b5a2cf90
2+
refs/heads/master: ba8750a5503242828ca0d95177196ebe6d7cbf51
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be

trunk/doc/tutorial.md

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -580,8 +580,8 @@ you use the matching to get at the contents of data types. Remember
580580
that `(float, float)` is a tuple of two floats:
581581

582582
~~~~
583-
use float::consts::pi;
584583
fn angle(vector: (float, float)) -> float {
584+
let pi = float::consts::pi;
585585
match vector {
586586
(0f, y) if y < 0f => 1.5 * pi,
587587
(0f, y) => 0.5 * pi,
@@ -601,23 +601,19 @@ an expression of type `bool` that determines, after the pattern is
601601
found to match, whether the arm is taken or not. The variables bound
602602
by the pattern are available in this guard expression.
603603

604-
## Let
605-
606-
You've already seen simple `let` bindings. `let` is also a little fancier: it
607-
is possible to use destructuring patterns in it. For example, you can say this
608-
to extract the fields from a tuple:
604+
You've already seen simple `let` bindings, but `let` is a little
605+
fancier than you've been led to believe. It too supports destructuring
606+
patterns. For example, you can say this to extract the fields from a
607+
tuple, introducing two variables, `a` and `b`.
609608

610609
~~~~
611610
# fn get_tuple_of_two_ints() -> (int, int) { (1, 1) }
612611
let (a, b) = get_tuple_of_two_ints();
613612
~~~~
614613

615-
This will introduce two new variables, `a` and `b`, bound to the
616-
content of the tuple.
617-
618-
You may only use *irrefutable* patterns—patterns that can never fail to
619-
match—in let bindings. Other types of patterns, such as literals, are
620-
not allowed.
614+
Let bindings only work with _irrefutable_ patterns, that is, patterns
615+
that can never fail to match. This excludes `let` from matching
616+
literals and most enum variants.
621617

622618
## Loops
623619

0 commit comments

Comments
 (0)