|
|
|
|
|
by masklinn
2221 days ago
|
|
> Rust doesn't allow to enum variables to be forward compatible, i.e. it cannot have a value outside of enum AKA Rust's enums are type-safe, not aliases for integers with some named constants. Rather than Rust's, I'd say the mistake is C's enums. If you don't want enums, don't have them. I guess that's one place where Go did something good: they didn't want to improve on C's enums with proper ADTs so they just stripped out the entire thing, an "enum" is an integer and a bunch of constants. Which you can also use to represent these non-enums in Rust though it doesn't have the iota / step convenience. A simple recursive macro might be able to handle it though. |
|