ralfbiedert / cheats.rs

Rust Language Cheat Sheet - https://cheats.rs
https://cheats.rs
4.14k stars 395 forks source link

error: the `?` macro repetition operator does not take a separator #183

Closed guilliamxavier closed 1 year ago

guilliamxavier commented 1 year ago

The "Macros & Attributes" section contains these three rows:

$(x),* Macro repetition REF zero or more times.
     $(x),? Same, but zero or one time.
     $(x),+ Same, but one or more times.

but the linked reference adds:

Since ? represents at most one occurrence, it cannot be used with a separator.

and indeed, trying to compile the following:

macro_rules! m {
    ($(x),*) => { $(x),* };
    ($(x),?) => { $(x),? };
    ($(x),+) => { $(x),+ };
}

gives an error (title of this issue) on the second rule (twice: for the matcher and for the transcriber).

PS: Thanks for the work!

ralfbiedert commented 1 year ago

Hah, thanks!