diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2015-05-01 11:12:16 +0530 |
|---|---|---|
| committer | Manish Goregaokar <manishsmail@gmail.com> | 2015-05-01 20:20:20 +0530 |
| commit | d3b7c5258f5b8871354e46bb60cca7d04be1b191 (patch) | |
| tree | 763580c351de5856f530521497178044ddfc2558 | |
| parent | 4fda7e8b389dc0666921c95be324b2ea66a00853 (diff) | |
| parent | 8c38dfd537eba8947d2397b9e3f4a56bdb0647fe (diff) | |
Rollup merge of #24992 - steveklabnik:gh24730, r=alexcrichton
Fixes #24730 r? @alexcrichton
| -rw-r--r-- | src/doc/reference.md | 9 | ||||
| -rw-r--r-- | src/doc/trpl/primitive-types.md | 8 |
2 files changed, 16 insertions, 1 deletions
diff --git a/src/doc/reference.md b/src/doc/reference.md index 6be67fc5144..3918a558cb3 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -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. ```{.tuple} -(0,); (0.0, 4.5); ("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 The expression `()` denotes the _unit value_, the only value of the type with diff --git a/src/doc/trpl/primitive-types.md b/src/doc/trpl/primitive-types.md index aca6e327c3b..e017e222c74 100644 --- a/src/doc/trpl/primitive-types.md +++ b/src/doc/trpl/primitive-types.md @@ -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. +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 You can also access fields of a tuple with indexing syntax: |
