Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Okay so, the issue here is that you two are speaking past each other. Enums in Rust are more than enums are in C. So this conversation is something like:

Them: I like sandwiches.

You: I get sandwiches from McDonalds, they're great.

Them: Yes, but those are burgers. (The implication being that there are also other kinds of sandwiches.)

You: Yes, burgers are good.

You're not wrong, but you're kind of missing what they're saying.

Enums in Rust can be like enums in C, but they can also be tagged unions. Furthermore, Rust won't automatically cast an enum to an int, so it is a bit harder to make mistakes, even if you're using the C-like ones. That's the advantages they're speaking about. Enums are good and useful in C, it's true. That's why Rust added stuff to make them even more useful.



Yup, plus the other uses have their own implementation. If you're doing arithmetics, in rust you probably want a constant. If you want a bitmask, there's bitfield crate (or a struct/enum with bitwise ops implemented).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: