14
submitted 3 days ago by [email protected] to c/[email protected]

I just learned the basics of macros and figured I'd give a shot trying to solve a problem I've had for a while. Theres just one derive trait in this crate, Variants, that when derived will generate a constant array that holds all of the enum's variants along with a method that exposes a static reference to the constant array.

Give it a look, leave some feedback, maybe even open up a PR. I hope you like what you see!

top 3 comments
sorted by: hot top new old
[-] [email protected] 8 points 3 days ago
[-] [email protected] 7 points 3 days ago

I wanted to learn how to write a simple macro and how to publish a crate.

[-] [email protected] 5 points 3 days ago

Fair enough!

this post was submitted on 29 May 2025
14 points (100.0% liked)

Rust

6956 readers
18 users here now

Welcome to the Rust community! This is a place to discuss about the Rust programming language.

Wormhole

[email protected]

Credits

  • The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)

founded 2 years ago
MODERATORS