[][src]Derive Macro d3_derive::MachineImpl

#[derive(MachineImpl)]

MachineImpl is a derive macro that tranforms an enum into an instruction set that can be implemented by machines.

Example

#[macro_use] extern crate d3_derive;
use d3_core::MachineImpl::*;

// instructions can be unit-like
#[derive(Debug, MachineImpl)]
pub enum StateTable {
    Init,
    Start,
    Stop,
}

// instructions can also be tupple, and struct
#[derive(Debug, MachineImpl)]
pub enum TrafficLight {
    Red(TrafficLightModality),
    Green(TrafficLightModality),
    Yellow(TrafficLightModality),
}

#[derive(Debug)]
pub enum TrafficLightModality {
    Solid,
    Blinking,
}

Instructions can be mixed
#[derive(Debug, MachineImpl)]
pub enum Calc {
    Clear,
    Add(u32),
    Sub(u32),
    Div(u32),
    Mul(u32),
}