Skip to content

Commit 0b50be9

Browse files
committed
Add some notes on repetition
1 parent 5e296d2 commit 0b50be9

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/macros-by-example.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ matches, in a structure that mimics the structure of the repetition encountered
5959
on a successful match. The job of the transcriber is to sort that structure
6060
out.
6161

62+
> **Edition Differences**: In the 2018 edition, a new Kleene operator was
63+
> added: `?` means "at most once". This operator only works in edition 2018 and
64+
> onward. `?` does not accept a repetition separator, unlike `+` and `*`.
65+
6266
The rules for transcription of these repetitions are called "Macro By Example".
6367
Essentially, one "layer" of repetition is discharged at a time, and all of them
6468
must be discharged by the time a name is transcribed. Therefore, `( $( $i:ident
@@ -89,4 +93,8 @@ Rust syntax is restricted in two ways:
8993
pairs when they occur at the beginning of, or immediately after, a `$(...)*`;
9094
requiring a distinctive token in front can solve the problem.
9195

96+
> **Edition Differences**: As of the 2018 edition, `?` is not allowed as a
97+
> repetition separator. This is to remove ambiguity with the new `?` Kleene
98+
> operator.
99+
92100
[RFC 550]: https://github.com/rust-lang/rfcs/blob/master/text/0550-macro-future-proofing.md

0 commit comments

Comments
 (0)