From 9509e743604eca7d72d4fa07857a205e72005799 Mon Sep 17 00:00:00 2001 From: Peter Jaszkowiak Date: Thu, 21 Dec 2023 22:00:13 -0700 Subject: [PATCH] Fix misleading explanation of comma in `$(),*` 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. --- src/ch19-06-macros.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ch19-06-macros.md b/src/ch19-06-macros.md index 7731869eae..20aa4e4a57 100644 --- a/src/ch19-06-macros.md +++ b/src/ch19-06-macros.md @@ -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`.