#enums #utils #macro

macro enum_all_variants

Generate a list of all enum variants in Rust

2 unstable releases

0.2.0 Mar 18, 2024
0.1.0 Oct 10, 2023

#356 in Procedural macros

Download history 5/week @ 2024-02-21 5/week @ 2024-02-28 1/week @ 2024-03-06 110/week @ 2024-03-13 28/week @ 2024-03-20 21/week @ 2024-03-27 26/week @ 2024-04-03

97 downloads per month

MIT license

4KB
58 lines

enum_all_variants

Proc macro for generating a list of all enum variants.

Example

use enum_all_variants::AllVariants;

#[derive(AllVariants, Debug)]
enum Direction {
    Left,
    Top,
    Right,
    Bottom,
}

fn main() {
    println!("{:?}", Direction::all_variants());
}

Outputs:

[Left, Top, Right, Bottom]

Dependencies

~305–760KB
~18K SLoC