Skip to content

Commit 716cea8

Browse files
committed
Singularize "the rest pattern"
Like "the wildcard pattern", there is only one "rest pattern". Let's singularize this and add the appropriate redirect.
1 parent 3bf9b5b commit 716cea8

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

book.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ use-boolean-and = true
3535
"/items/traits.html#object-safety" = "traits.html#dyn-compatibility"
3636
"/lifetime-elision.html#static-lifetime-elision" = "lifetime-elision.html#const-and-static-elision"
3737
"/macros-by-example.html#path-based-scope" = "macros-by-example.html#the-macro_export-attribute"
38+
"/patterns.html#rest-patterns" = "patterns.html#rest-pattern"
3839
"/procedural-macros.html#attribute-macros" = "procedural-macros.html#the-proc_macro_attribute-attribute"
3940
"/procedural-macros.html#derive-macros" = "procedural-macros.html#the-proc_macro_derive-attribute"
4041
"/procedural-macros.html#function-like-procedural-macros" = "procedural-macros.html#the-proc_macro-attribute"

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.

src/syntax-index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ This appendix provides an index of tokens and common forms with links to where t
100100
| `<=` | Le | [less than or equal to][comparison] |
101101
| `@` | At | [subpattern binding] |
102102
| `.` | Dot | [field access][field], [tuple index] |
103-
| `..` | DotDot | [range expressions][expr.range], [struct expressions], [rest patterns], [range patterns], [struct patterns] |
103+
| `..` | DotDot | [range expressions][expr.range], [struct expressions], [rest pattern], [range patterns], [struct patterns] |
104104
| `...` | DotDotDot | [variadic functions], [range patterns] |
105105
| `..=` | DotDotEq | [inclusive range expressions][expr.range], [range patterns] |
106106
| `,` | Comma | various separators |
@@ -258,7 +258,7 @@ This appendix provides an index of tokens and common forms with links to where t
258258
| `"foo"`, `'a'`, `123`, `2.4`, … | [literal patterns] |
259259
| `ident` | [identifier patterns] |
260260
| `_` | [wildcard pattern] |
261-
| `..` | [rest patterns] |
261+
| `..` | [rest pattern] |
262262
| `..`, `a..`, `..b`, `a..b`, `a..=b`, `..=b` | [range patterns] |
263263
| `&pattern`<br>`&mut pattern` | [reference patterns] |
264264
| `path {…}` | [struct patterns] |
@@ -403,7 +403,7 @@ This appendix provides an index of tokens and common forms with links to where t
403403
[relaxed trait bounds]: bound.sized
404404
[repeat array expressions]: expr.array
405405
[reserved keyword]: lex.keywords.reserved
406-
[rest patterns]: patterns.rest
406+
[rest pattern]: patterns.rest
407407
[return expressions]: expr.return
408408
[self parameters]: items.fn.params.self-pat
409409
[single-element tuple expressions]: expr.tuple

0 commit comments

Comments
 (0)