Crate enum_derived

source ·
Expand description

Enum-Derived adds new functionality to unit-like enums


You may be looking for:

Enum-Derived in action

use enum_derived::Rand;

#[derive(Rand, Debug)]
pub enum Dna {
    A,
    C,
    T,
    G
}

fn main() {

    let base = Dna::rand();

    println!("Random Base: ${base:?}");
}

Derive Macros

Rand creates an associated rand method that returns a random variant of the enum when called