#enums #values #enumerate #derive #derive-debug #food #clone

enumerable

A library helping you to enumerate all possible values of a type

2 unstable releases

0.2.0 Apr 27, 2024
0.1.0 Apr 8, 2024

#635 in Rust patterns

Download history 99/week @ 2024-04-02 44/week @ 2024-04-09 126/week @ 2024-04-23 18/week @ 2024-04-30

287 downloads per month

MIT license

14KB
238 lines

enumerable

Enumerate all possible values of a type.

Guide

use enumerable::Enumerable;

#[derive(Debug, Copy, Clone, Enumerable)]
enum Food {
    Apple,
    Banana,
    Carrot,
    Donut,
}

#[derive(Debug, Copy, Clone, Enumerable)]
struct Meal {
    alice_eats: Food,
    bob_eats: Option<Food>,
    at_home: bool,
}

fn main() {
    for meal in Meal::enumerator() {
        println!("{:?}", meal);
    }
}

See the documentation for more information.

See the examples for more examples.

Dependencies

~315–770KB
~18K SLoC