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...
When a single target state is defined in the
machine::transitions!()macro for a specific transition,machinewill 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,machinegenerates 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
StateOneOrStateTwoOrStateFourteenOrStateFiftybut I don't see how else it could be done...