A bad-ass macro (or set of macros) to reduce repetition with method generators
Opened this issue · 0 comments
One thing I've noticed when writing method generators is that they have a lot of repetitive boilerplate. For example, in getters.rs:impl_enum_as_getters, there are four variables created, twice in that same method, that do very similar things:
variant_namesfunction_namesfunction_name_strsvariant_types
The recreation and repetition is unavoidable, because of limitations in the quote crate. There are minor differences between each creation, but syntactically, has the same structure.
And this is just one example. It's like this in every generator method as far as I'm aware. Hypothetically, we could keep doing it this way, with lots of copy/paste-driven development. But I feel like there's a better way.
Anyway, if you're looking to get your hands dirty with some Rust macros, feel free to give this a shot and let me know what you find.