Posted on c/ElrondDevelopers 2 mic49732581c/ElrondDevelopers 2 years ago Is there a way to convert an enum to u8 in rust? Comment 2 Comments dra8809196860 2years ago #[derive(Copy, Clone)] enum Foo { Bar = 1, } fn f(foo: &Foo) -> u8 { *foo as u8 } Try this ian8639380436 2years ago I suggest you use Rust's pattern matching instead of whatever you're trying to do.
#[derive(Copy, Clone)] enum Foo { Bar = 1, } fn f(foo: &Foo) -> u8 { *foo as u8 } Try this
I suggest you use Rust's pattern matching instead of whatever you're trying to do.