These are chat archives for rust-lang/rust

17th
Jun 2017
Gwen Lofman
@glfmn
Jun 17 2017 21:15

I'm trying to write a macro that lets me define an enum like so:

enum_range!( Pattern {C(1; 106)} );

Which results in

enum Pattern {
    C1,
    C2,
    C3,
// ....
    C106,
}

The part I'm stuck on is generating a sequence of identifiers from C1 to C106, if that's possible at all. Is there any way to generate a range of numbers in a macro, and then concatenate them to the end of C? Should I use a token tree? Expression? Identifiers?

Denis Lisov
@tanriol
Jun 17 2017 21:48
Likely to be impossible without hacks based on macros 1.1