Skip to content

Add new function to perform transition using message enum as input #17

Description

@johanmazel

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),
    }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions