4 ms·
Coming from C/C++, "enums with data" sound more interesting to me than "unions with a type", even though they describe the same thing. I used C/C++ enums far mo
by jkarneges 5y ago
Coming from C/C++, "enums with data" sound more interesting to me than "unions with a type", even though they describe the same thing. I used C/C++ enums far more often than unions, and often wished I could add extra data to them.
Another thing is that adding data to Rust enums is optional, and so you can have an enum of variants with no data. The union equivalent to that would be a type-only union which sounds kind of odd.