Skip to content

Commit a48cad1

Browse files
authored
Merge pull request #2061 from ehuss/syntax-index
Move punctuation index to an appendix, and expand for other syntaxes
2 parents e939a19 + e93dce5 commit a48cad1

File tree

5 files changed

+474
-102
lines changed

5 files changed

+474
-102
lines changed

book.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ level = 0
1818
use-boolean-and = true
1919

2020
[output.html.search.chapter]
21-
"test-summary.md" = { enable = false }
2221
"grammar.md" = { enable = false }
22+
"syntax-index.md" = { enable = false }
23+
"test-summary.md" = { enable = false }
2324

2425
[output.html.redirect]
2526
"/crates-and-source-files.html#preludes-and-no_std" = "names/preludes.html"
@@ -36,6 +37,7 @@ use-boolean-and = true
3637
"/items/traits.html#object-safety" = "traits.html#dyn-compatibility"
3738
"/lifetime-elision.html#static-lifetime-elision" = "lifetime-elision.html#const-and-static-elision"
3839
"/macros-by-example.html#path-based-scope" = "macros-by-example.html#the-macro_export-attribute"
40+
"/patterns.html#rest-patterns" = "patterns.html#rest-pattern"
3941
"/procedural-macros.html#attribute-macros" = "procedural-macros.html#the-proc_macro_attribute-attribute"
4042
"/procedural-macros.html#derive-macros" = "procedural-macros.html#the-proc_macro_derive-attribute"
4143
"/procedural-macros.html#function-like-procedural-macros" = "procedural-macros.html#the-proc_macro-attribute"

src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@
133133

134134
- [Appendices](appendices.md)
135135
- [Grammar summary](grammar.md)
136+
- [Syntax index](syntax-index.md)
136137
- [Macro follow-set ambiguity formal specification](macro-ambiguity.md)
137138
- [Influences](influences.md)
138139
- [Test summary](test-summary.md)

src/patterns.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ Destructuring breaks up a value into its component pieces.
9393
The syntax used is almost the same as when creating such values.
9494

9595
r[patterns.destructure.wildcard]
96-
In a pattern whose [scrutinee] expression has a `struct`, `enum` or `tuple` type, a [wildcard pattern](#wildcard-pattern) (`_`) stands in for a *single* data field, whereas an [et cetera](#grammar-StructPatternEtCetera) or [rest pattern](#rest-patterns) (`..`) stands in for *all* the remaining fields of a particular variant.
96+
In a pattern whose [scrutinee] expression has a `struct`, `enum` or `tuple` type, a [wildcard pattern](#wildcard-pattern) (`_`) stands in for a *single* data field, whereas an [et cetera](#grammar-StructPatternEtCetera) or [rest pattern][patterns.rest] (`..`) stands in for *all* the remaining fields of a particular variant.
9797

9898
r[patterns.destructure.named-field-shorthand]
9999
When destructuring a data structure with named (but not numbered) fields, it is allowed to write `fieldname` as a shorthand for `fieldname: fieldname`.
@@ -421,7 +421,7 @@ r[patterns.wildcard.refutable]
421421
The wildcard pattern is always irrefutable.
422422

423423
r[patterns.rest]
424-
## Rest patterns
424+
## Rest pattern
425425

426426
r[patterns.rest.syntax]
427427
```grammar,patterns
@@ -470,7 +470,8 @@ if let [.., penultimate, _] = slice {
470470
}
471471

472472
# let tuple = (1, 2, 3, 4, 5);
473-
// Rest patterns may also be used in tuple and tuple struct patterns.
473+
// The rest pattern may also be used in tuple and tuple
474+
// struct patterns.
474475
match tuple {
475476
(1, .., y, z) => println!("y={} z={}", y, z),
476477
(.., 5) => println!("tail must be 5"),
@@ -974,7 +975,7 @@ r[patterns.slice.refutable-array]
974975
Slice patterns are irrefutable when matching an array as long as each element is irrefutable.
975976

976977
r[patterns.slice.refutable-slice]
977-
When matching a slice, it is irrefutable only in the form with a single `..` [rest pattern](#rest-patterns) or [identifier pattern](#identifier-patterns) with the `..` rest pattern as a subpattern.
978+
When matching a slice, it is irrefutable only in the form with a single `..` [rest pattern][patterns.rest] or [identifier pattern](#identifier-patterns) with the `..` rest pattern as a subpattern.
978979

979980
r[patterns.slice.restriction]
980981
Within a slice, a range pattern without both lower and upper bound must be enclosed in parentheses, as in `(a..)`, to clarify it is intended to match against a single slice element.

0 commit comments

Comments
 (0)