Rust: How to println!() the numerical value of an enum variant?
enum Pets {
Cat = 0,
Dog,
Hamster,
GuineaPig,
Ferret
}
fn main() {
let my_pet = Pets::Cat;
println!("{}", my_pet);
}
Is there a way to make this code print the numerical value of the enum? I.e. 0 for my_pet == Pets::Cat, 1 for my_pet == Pets::Dog, and so on... Thanks!