Skip to content

Commit 13ae522

Browse files
committed
Rollup merge of #24992 - steveklabnik:gh24730, r=alexcrichton
Fixes #24730 r? @alexcrichton
2 parents f157525 + 8c38dfd commit 13ae522

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/doc/reference.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2425,11 +2425,18 @@ Tuples are written by enclosing zero or more comma-separated expressions in
24252425
parentheses. They are used to create [tuple-typed](#tuple-types) values.
24262426

24272427
```{.tuple}
2428-
(0,);
24292428
(0.0, 4.5);
24302429
("a", 4usize, true);
24312430
```
24322431

2432+
You can disambiguate a single-element tuple from a value in parentheses with a
2433+
comma:
2434+
2435+
```
2436+
(0,); // single-element tuple
2437+
(0); // zero in parentheses
2438+
```
2439+
24332440
### Unit expressions
24342441

24352442
The expression `()` denotes the _unit value_, the only value of the type with

src/doc/trpl/primitive-types.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,14 @@ or “breaks up” the tuple, and assigns the bits to three bindings.
248248

249249
This pattern is very powerful, and we’ll see it repeated more later.
250250

251+
You can disambiguate a single-element tuple from a value in parentheses with a
252+
comma:
253+
254+
```
255+
(0,); // single-element tuple
256+
(0); // zero in parentheses
257+
```
258+
251259
## Tuple Indexing
252260

253261
You can also access fields of a tuple with indexing syntax:

0 commit comments

Comments
 (0)