Skip to content
This repository was archived by the owner on Sep 15, 2026. It is now read-only.
This repository was archived by the owner on Sep 15, 2026. It is now read-only.

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

Description

@alekratz

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.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions