Closed
Description
#[deriving(Show)]
enum State {
AtoZ(uint),
Numeric,
}
fn main() {
let state = Numeric;
let b = 97u8; // a
let r = match (state, b as char) {
(AtoZ(..), 'a'..'z') => {
"Named"
},
(Numeric, 'x') => {
"Hex"
},
_ => {
"Other"
}
};
println!("{} {}: {}", state, b as char, r);
}
Outputs Numeric a: Hex
. Clearly, a
shouldn't match x
.
Worth noting: if you change the first range to not include x
, such as a
..w
, it works correctly. Also, removing the field from AtoZ
also makes the match work correctly.