I have an enum:
enum Foo {
Bar = 1,
}
How do I convert a reference to this enum into an integer to be used in math?
fn f(foo: &Foo) {
let f = foo as u8; // error[E0606]: casting `&Foo` as `u8` is invalid
let f = foo as &u8; // error[E0605]: non-primitive cast: `&Foo` as `&u8`
let f = *foo as u8; // error[E0507]: cannot move out of borrowed content
}