Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A bad-ass macro (or set of macros) to reduce repetition with method generators #16

Open
alekratz opened this issue Sep 15, 2017 · 0 comments

Comments

@alekratz
Copy link
Owner

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_names
  • function_names
  • function_name_strs
  • variant_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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant