3 ms·
However, Rust's enum-type members are still named - to my knowledge you can't have anonymous enum type members in Rust. In the example you gave, the type-of `l
by DaiPlusPlus 6y ago
However, Rust's enum-type members are still named - to my knowledge you can't have anonymous enum type members in Rust.
In the example you gave, the type-of `left` is still `SumType::Left` instead of being just `String`.
I'm not too familiar with Rust to say, but I don't consider this to be a syntactically zero-cost abstraction (even if the wrapper-types are elided by the compiler) because we still have more keyboard typing to do than we should be doing, imo.
- renewiltord 6y agoAh, that's to enable you to have multiple members that could hold `String` values. Yeah, it comes with the (syntactic) cost that you have to identify the member.
- ATsch 6y agoIn practice that's really not a problem because of rust's great pattern matching that easily lets you extract even deeply nested values.