diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2015-02-23 14:45:05 +0530 |
|---|---|---|
| committer | Manish Goregaokar <manishsmail@gmail.com> | 2015-02-23 23:28:48 +0530 |
| commit | 4e73d4950d6ec0a955c66bd41c4f00d5f4ddb4ca (patch) | |
| tree | bd53711dc2c569a95dcff0d6af361eb95da2bda8 /src/doc/reference.md | |
| parent | f0085060fe955d4ec26db57d2a80dbc78f96beb7 (diff) | |
| parent | 928341e18890c0fec910a0dc92ef7f36e01a8d65 (diff) | |
| download | rust-4e73d4950d6ec0a955c66bd41c4f00d5f4ddb4ca.tar.gz rust-4e73d4950d6ec0a955c66bd41c4f00d5f4ddb4ca.zip | |
Rollup merge of #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.
Diffstat (limited to 'src/doc/reference.md')
| -rw-r--r-- | src/doc/reference.md | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/doc/reference.md b/src/doc/reference.md index f8bc151ee7f..357ff813fef 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -3557,7 +3557,8 @@ Tuple types and values are denoted by listing the types or values of their elements, respectively, in a parenthesized, comma-separated list. Because tuple elements don't have a name, they can only be accessed by -pattern-matching. +pattern-matching or by using `N` directly as a field to access the +`N`th element. An example of a tuple type and its use: @@ -3566,6 +3567,7 @@ type Pair<'a> = (i32, &'a str); let p: Pair<'static> = (10, "hello"); let (a, b) = p; assert!(b != "world"); +assert!(p.0 == 10); ``` ### Array, and Slice types |
