-
Notifications
You must be signed in to change notification settings - Fork 28
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
Fixing the internal state management, reverting actions to take references to state data, cleaning up codegen #76
Conversation
cc @korken89 / @dzimmanck / @pleepleus - I don't think I can review/approve/merge without one of you guys signing off |
Nice catch! If you get the changelog fixed I'll merge it :) |
Just for my understanding, why is in-place replacing the state is not used? It would catch these errors at compile-time. |
It appears that the in-place swap-over of the state to With respect to the CHANGELOG, would you still prefer this existed there? Generally, in other projects, when I introduce a bug and then fix it before said bug is released, I haven't included it in the CHANGELOG to prevent noise. I'm happy to add it in, just wanted to clarify first |
Ah sorry I thought the bug was existing between releases, no changelog needed :) I generally use the following create to do in place state management. Though it was not added at the std lib for good reason. Though this is not the correct PR to change it. A closure that works on top of the option would also give the same guarantees and not tred on the limits of what Rust can do. :) |
Edit: The However, the more I'm thinking about that, the more I think that we should perhaps revert #49. If a user has a large, non-clonable state data, I imagine they could put that in some type of Will take a look at the closure based approach though. I agree that #49 has made the internal state pretty fragile. It seems nonsensical that there can be |
Yeah, to me I like replace_with just because it makes the compiler enforce that all transitions are correct and you don't need any intermediate representation. Using an option is fine though as well with the closure support, it will give the same result without unsafe. :) Here is an implementation example: |
There's actually some issues with #49 specifically w.r.t fallible actions. If the This shows up when trying this closure-based approach, as you can't pass the I think the only valid approaches would be to revert #49 or to use |
Yeah, you really need to be careful when you can move stuff out. Which way to go is not clear to me, I'm not sure how much work it works be to use replace_with. The revert is the easy option :) |
Looking at it further, I think the only fix here is to remove ownership of internal state data in |
Alright, then the path is set! :) |
Alright, the reversion should be complete here. Thanks for the discussion @korken89 :) |
Thanks for doing the analysis! :D |
Fixes #75 by reconfiguring the state if the guard fails. We were unintentionally bailing immediately with no internal state configured due to the
?
operation.