If I have this code:
enum Test {
One(u32),
Two(u32),
Three(u32),
Four(u32),
Five(u32)
}
impl Test {
pub fn val(&self) -> u32 {
match *self {
Test::One(val) => val,
Test::Two(val) => val,
Test::Three(val) => val,
Test::Four(val) => val,
Test::Five(val) => val
}
}
}
Does anyone know if that results in a whole mess of conditionals? Or is this pattern detected by an optimizer durring compilation?
Or should I do something like:
enum TestType {
One,
Two,
Three,
Four,
Five
}
struct Test {
test_type : TestType,
value : u32
}