Derive Macro IterableEnum

Source
#[derive(IterableEnum)]
Expand description

Derive macro that generates an iterator over all enum variants. This creates a method iter() that returns an iterator over all possible values of the enum.

ยงExample

use slang_derive::IterableEnum;

#[derive(Debug, Copy, Clone, IterableEnum)]
enum Color {
    Red,
    Green,
    Blue,
}

// Iterate over all enum values
for color in Color::iter() {
    println!("{:?}", color);
}

This macro only works with enums that have no associated data (unit variants only).