Rollup merge of #24992 - steveklabnik:gh24730, r=alexcrichton
Fixes #24730 r? @alexcrichton
This commit is contained in:
commit
d3b7c5258f
src/doc
@ -2425,11 +2425,18 @@ Tuples are written by enclosing zero or more comma-separated expressions in
|
|||||||
parentheses. They are used to create [tuple-typed](#tuple-types) values.
|
parentheses. They are used to create [tuple-typed](#tuple-types) values.
|
||||||
|
|
||||||
```{.tuple}
|
```{.tuple}
|
||||||
(0,);
|
|
||||||
(0.0, 4.5);
|
(0.0, 4.5);
|
||||||
("a", 4usize, true);
|
("a", 4usize, true);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
You can disambiguate a single-element tuple from a value in parentheses with a
|
||||||
|
comma:
|
||||||
|
|
||||||
|
```
|
||||||
|
(0,); // single-element tuple
|
||||||
|
(0); // zero in parentheses
|
||||||
|
```
|
||||||
|
|
||||||
### Unit expressions
|
### Unit expressions
|
||||||
|
|
||||||
The expression `()` denotes the _unit value_, the only value of the type with
|
The expression `()` denotes the _unit value_, the only value of the type with
|
||||||
|
@ -248,6 +248,14 @@ or “breaks up” the tuple, and assigns the bits to three bindings.
|
|||||||
|
|
||||||
This pattern is very powerful, and we’ll see it repeated more later.
|
This pattern is very powerful, and we’ll see it repeated more later.
|
||||||
|
|
||||||
|
You can disambiguate a single-element tuple from a value in parentheses with a
|
||||||
|
comma:
|
||||||
|
|
||||||
|
```
|
||||||
|
(0,); // single-element tuple
|
||||||
|
(0); // zero in parentheses
|
||||||
|
```
|
||||||
|
|
||||||
## Tuple Indexing
|
## Tuple Indexing
|
||||||
|
|
||||||
You can also access fields of a tuple with indexing syntax:
|
You can also access fields of a tuple with indexing syntax:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user