Skip to content

Commit 8d1753b

Browse files
committed
Rollup merge of rust-lang#22660 - achernya:tuple-reference, r=alexcrichton
The Rust Reference should include the tuple indexing (using a number as a field) notation; currently it is only available on http://doc.rust-lang.org/std/primitive.tuple.html and not easily searchable.
2 parents 375c75c + 928341e commit 8d1753b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/doc/reference.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3557,7 +3557,8 @@ Tuple types and values are denoted by listing the types or values of their
35573557
elements, respectively, in a parenthesized, comma-separated list.
35583558

35593559
Because tuple elements don't have a name, they can only be accessed by
3560-
pattern-matching.
3560+
pattern-matching or by using `N` directly as a field to access the
3561+
`N`th element.
35613562

35623563
An example of a tuple type and its use:
35633564

@@ -3566,6 +3567,7 @@ type Pair<'a> = (i32, &'a str);
35663567
let p: Pair<'static> = (10, "hello");
35673568
let (a, b) = p;
35683569
assert!(b != "world");
3570+
assert!(p.0 == 10);
35693571
```
35703572

35713573
### Array, and Slice types

0 commit comments

Comments
 (0)