#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

#66 in #enum

Download history 61/week @ 2024-11-13 91/week @ 2024-11-20 88/week @ 2024-11-27 136/week @ 2024-12-04 136/week @ 2024-12-11 92/week @ 2024-12-18 12/week @ 2024-12-25 8/week @ 2025-01-01 48/week @ 2025-01-08 73/week @ 2025-01-15 80/week @ 2025-01-22 49/week @ 2025-01-29 116/week @ 2025-02-05 111/week @ 2025-02-12 11/week @ 2025-02-19 62/week @ 2025-02-26

310 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

~200–630KB
~15K SLoC