by consteval · 2y ago · 0 comments
You also can't add them, or subtract them.
Yes behind the scenes their integers, but almost certainly this is the case in Rust too. You can SOMETIMES coerce an enum class instance back to an int if you do unsafe casts (on purpose).
However whether you can add or subtract them is harder to guess than you seem to have assumed
https://godbolt.org/z/3vdazcr7E
Of course the bit pattern representation is the same in Rust. The point isn't the representation or we'd be talking about machine code. The point is the ergonomics.
These types aren't (shouldn't be) integers, but in C and C++ they are anyway.