Skip to content

Commit 928341e

Browse files
committed
Include tuple indexing in the Reference.
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.
1 parent 2b01a37 commit 928341e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/doc/reference.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -3554,7 +3554,8 @@ Tuple types and values are denoted by listing the types or values of their
35543554
elements, respectively, in a parenthesized, comma-separated list.
35553555

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

35593560
An example of a tuple type and its use:
35603561

@@ -3563,6 +3564,7 @@ type Pair<'a> = (i32, &'a str);
35633564
let p: Pair<'static> = (10, "hello");
35643565
let (a, b) = p;
35653566
assert!(b != "world");
3567+
assert!(p.0 == 10);
35663568
```
35673569

35683570
### Array, and Slice types

0 commit comments

Comments
 (0)