Skip to content

Transitions to multiple targets is not type safe as it could #20

@nbigaouette-eai

Description

@nbigaouette-eai

When a single target state is defined in the machine::transitions!() macro for a specific transition, machine will generate a method that return the exact struct of the target, making this transition type safe: When implementing that transition, returning the wrong state will fail compilation.

But when multiple target states are defined in the machine::transitions!() macro, machine generates a method that returns the main enum. This means that those transitions user implementations can be wrong and not match what the macro contains.

I think the only type-safe way of doing this would be to generate a different enum for transitions to multiple targets. This would unfortunately create some monster enums like StateOneOrStateTwoOrStateFourteenOrStateFifty but I don't see how else it could be done...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions