5 ms·
Anonymous sum types. Most enum variants I write are single use, or very few use. We have anonymous product/record types with tuples (function returns all-of) bu
by qppo 7y ago
Anonymous sum types. Most enum variants I write are single use, or very few use. We have anonymous product/record types with tuples (function returns all-of) but not variants (function returns one-of). Something like fn foo() -> (i32 | f32 | String). I'm not the first person to suggest this idea, and it's been done in other languages.
As well, having to match against Enum::Variant0, EnumVariant::1, etc, for all arms of a match statement instead of inferring that it would be Variant0, Variant1 is tedious.
These changes would be difficult to implement and I know some people prefer to have all of the explicitness in their code. But one of the most common complaints outside the community is that prototyping in Rust is slow. Not just because of the borrow checker, that's easy once you learn it. It's the over-emphasis on explicitness at the expense of ergonomics.