4 ms·
Unions discriminated by type could be useful in Rust, especially if you could use them without declaring the union type explicitly. It'd enable something like `
by CodesInChaos 6y ago
Unions discriminated by type could be useful in Rust, especially if you could use them without declaring the union type explicitly. It'd enable something like `Result<..., IoError | ParseError>` without having to manually create a union type, implement the appropriate traits for it, etc. Unfortunately it opens a can of worms related to type identity, so I don't expect to see such a feature soon.
- steveklabnik 6y agoThere are a group of people pushing for it ("anonymous enums") but it is unclear if it will ever happen or not, yes.