Re:Using enums to represent state in Rust
by newZWhoDis on Friday September 22, 2023 @09:46AM
(#37612006)
Probably my favorite aspect of Swift as well, enums + payloads/associated types make for extremely safe and easy to understand code.
Combine it with switches and you get compiler guarantees that every state is explicitly handled, and if you are in a particular state you always have the relevant child objects.
I remember being shocked dart lacked this functionality when I tried out flutter.
Combine it with switches and you get compiler guarantees that every state is explicitly handled, and if you are in a particular state you always have the relevant child objects.
I remember being shocked dart lacked this functionality when I tried out flutter.