It would be nice to extend the enum module that contains states and add an additional function to execute transitions using the message enum, instead of executing transition by using message specific function.
This function would be similar to the execute
function in the crate macro_machine or the handle_event
function in macro_machines.
For the example provided in the doc, in the module Traffic, this new function would be something like:
fn execute(t: &Traffic, m: &TrafficMessages) -> Traffic {
match m {
TrafficMessages::Advance(advance) => t.on_advance(advance),
TrafficMessages::PassCar(pass_car) => t.on_pass_car(pass_car),
}
}