Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
nbigaouette-eai opened this issue Aug 8, 2019 · 0 comments
Open

Comments

@nbigaouette-eai
Copy link

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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant