Macro_rules + repetition + stringify

How could one implement a macro (called symbols! in the following example) that stringifies the identifiers it receives separately, like this:

symbols![a b c de fgh] => vec!["a", "b", "c", "de", "fgh"]

?

Hmm, not sure what I was doing wrong before, this seems to work:

macro_rules! symbols {
    ($($s:ident)*) => {
        vec![$(stringify!($s)),*]
    };
}
2 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.