Re:Using enums to represent state in Rust
by 0x457 on Friday September 22, 2023 @02:37PM
(#37615902)
They do, but IIRC this mostly to compare enum variants when it can't implement `Eq` and/or `PartialEq`. For example, in tests.
There are also zero variants enums that don't have any discriminant, but still could be used.
I'm not sure what's the point of comparing it to C because enums in C only carry tags and no data, while unions only carry data and no tag. Enums in rust could do both.
Their representation in memory may not use it, but it's still defined.