Skip to content

Commit

Permalink
Fix misleading explanation of comma in $(),*
Browse files Browse the repository at this point in the history
The previous explanation makes it sound like the comma in that place would match an optional trailing comma like in `[a, b, c,]`. That is incorrect, and actually that only matches commas between elements.
  • Loading branch information
pitaj authored Dec 22, 2023
1 parent 71352de commit 9509e74
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/ch19-06-macros.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,9 @@ for use in the replacement code. Within `$()` is `$x:expr`, which matches any
Rust expression and gives the expression the name `$x`.

The comma following `$()` indicates that a literal comma separator character
could optionally appear after the code that matches the code in `$()`. The `*`
specifies that the pattern matches zero or more of whatever precedes the `*`.
must appear between each instance of the code that matches the code within
`$()`. The `*` specifies that the pattern matches zero or more of whatever
precedes the `*`.

When we call this macro with `vec![1, 2, 3];`, the `$x` pattern matches three
times with the three expressions `1`, `2`, and `3`.
Expand Down

0 comments on commit 9509e74

Please sign in to comment.