| > To which language? I mean more in the sense of "where did you get this definition from." > The difference there is in the types the enums are applied to. In one case, a basic integer-based type. In the other, a class. I'm still not seeing a difference, mainly because when I went to see how c++'s `enum class` and rust's `enum`, they both seemed to work the same. #[repr(u8)]
enum Words {
Foo = 0,
Bar,
Baz,
}
const _: () = {
assert!(Words::Foo as u8 == 0);
assert!(Words::Bar as u8 == 1);
assert!(Words::Baz as u8 == 2);
};
vs enum class Words : uint8_t {
Foo = 0,
Bar,
Baz
};
static_assert(static_cast<uint8_t>(Words::Foo) == 0);
static_assert(static_cast<uint8_t>(Words::Bar) == 1);
static_assert(static_cast<uint8_t>(Words::Baz) == 2);
|
In other words, you want to have a conversation with someone else by proxy? If that's the case, why not just go talk the other people you'd really prefer to talk to?
> I'm still not seeing a difference
There is no difference. I recant what I said. This (strangely, undocumented in the above link) functionality does, in fact, provide use of enums.
Curious addition to the language. Especially when you consider how unsafe enums are. When would you ever use it? It is at least somewhat understandable in C++ as it may be helpful to "drop down" to work with the standard enum construct in some migratory situations, but when do you use it in Rust?