Closed
Description
Consider the following code:
fn main() {
enum E {
A,
B,
}
let x = E::A;
let y = true;
match x {
E::A | E::B if !y => println!("if applies only to last pattern"),
_ => println!("if applies to all OR'd patterns"),
}
}
The behaviour of this code depends on whether the guard applies to only the pattern it succeeds, or to the entire match arm. Running it on nightly behaves as though the guard applies to the entire arm (i.e. the first arm is not matched), but this is not stipulated anywhere in the docs as far as I can tell. If this interpretation of the code is indeed the expected one, then this should be documented.
Metadata
Metadata
Assignees
Labels
No labels