Is there a way to do a C ++ style enumeration with an explicit view type in Rust? Example:
enum class Number: int16_t {
Zero, One, Two, Three, Four, Five, Six, Seven, Eight, Nine
};
If not, is there another way to organize such variables? I interact with an external library, so it is important to specify the type. I know I can just do:
type Number = int16_t;
let One: Number = 1;
let Two: Number = 2;
let Three: Number = 3;
But this, in my opinion, represents a lot of redundancy;
Note that this question is not a duplicate. Is it possible to wrap C enums in Rust? , since this is a C ++ wrapper, not a C wrapper.
source
share