Re:Using enums to represent state in Rust
by zozbot234 on Friday September 22, 2023 @10:17AM
(#37612383)
> Rust ADTs and pattern matching are so much better than other mainstream languages
Pascal and Delphi have always had variant records as part of the language. Are these not "mainstream" enough, especially Delphi?
Re:Using enums to represent state in Rust
by diarrhea on Friday September 22, 2023 @10:25AM
(#37612495)
Uuugh, no. Not anymore at least.
Re:Using enums to represent state in Rust
by LoganDark on Friday September 22, 2023 @11:42AM
(#37613500)
Those languages have other issues that make them weird to use. Rust has its fair share of weirdness as well, but most of that weirdness is just a direct side effect of the way that it is.
Re:Using enums to represent state in Rust
by Klonoar on Friday September 22, 2023 @02:07PM
(#37615475)
Neither has been mainstream in years.
Re:Using enums to represent state in Rust
by metaltyphoon on Friday September 22, 2023 @07:31PM
(#37619137)
I wish it had nested object destructions like C# has. The best part of it all is that it can return expressions.
The next step is to encode your transition logic in the From impls between the enum structs and you've got yourself a first-rate state machine.