UPDATE: Use Type-State pattern without the ugly code (state-shift)
If you haven’t heard about state-shift, here is the old post: https://www.reddit.com/r/rust/comments/1fqstm8/use\_typestate\_pattern\_without\_the\_ugly\_code
And here is the readme: https://github.com/ozgunozerk/state-shift/blob/main/README.md
When I released the first version, it was more of an MVP.
With amazing feedback and contributions from the community (that’s you there, hi!), the library is now much more refined, stable and feature-full.
Here are the biggest changes since the beginning:
- generics, lifetimes, and visibility of the structs and methods are preserved (thanks to Johannes Kneer)
- using full path for
PhantomDatainstead of importing it (thanks to Sean P. Kelly) - Instead of having
PhantomData<T>in the hidden_statefield, we now havePhantomData<fn() -> State>. This makes is less strict for our struct to implementSend + Sync. (thanks to Veetaha -author of bon-)
Long story short, v1.0.0 is out 🚀
Feel free to use it and find even more bugs 🐞
And as always, everyone is welcome submit an issue or PR for anything.
GitHub link of the repo: https://github.com/ozgunozerk/state-shift
Thanks everyone! This community helped me so much in my Rust journey,
trying my best to return the favor 🦀