#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

#167 in #util

Download history 13/week @ 2024-07-22 54/week @ 2024-07-29 9/week @ 2024-08-05 25/week @ 2024-08-12 21/week @ 2024-08-19 50/week @ 2024-08-26 16/week @ 2024-09-02 2/week @ 2024-09-16 85/week @ 2024-09-23 45/week @ 2024-09-30 109/week @ 2024-10-07 52/week @ 2024-10-14 49/week @ 2024-10-21 56/week @ 2024-10-28 63/week @ 2024-11-04

224 downloads per month
Used in 7 crates (2 directly)

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

~225–670KB
~16K SLoC