Re:Using enums to represent state in Rust
by zozbot234 on Friday September 22, 2023 @12:21PM
(#37613996)
The point is that you only have to do it once, when defining the object. Everything else then happens via the From and Into implementations, which the compiler will generally be smart enough to inline. So it'll be just as efficient as working on the underlying u8.
Re:Using enums to represent state in Rust
by brigadier132 on Friday September 22, 2023 @12:35PM
(#37614182)
You have to do it once for each subset of variants your state machine requires. Which if you enumerate them all is 2^N from implementations.
It gets verbose fast when you are talking about all combinations of variants of an enum.