why does the @ operator have a lower precedence than |?
I discovered the @ operator today after over a year of rust, and I was initially very happy and pleased until I tried it out:
fn main() {
match 1 {
num @ 1 | 2 => {
println!("{}", num);
}
_ => {}
}
}
yields
error[E0408]: variable `num` is not bound in all patterns
--> src/main.rs:3:19
|
3 | num @ 1 | 2 => {
| --- ^ pattern doesn't bind `num`
| |
| variable not in all patterns
I was dumbstruck. this was a complete dealbreaker for me, and I may be missing something, but I feel like this error could be done away with if the @ operator had a higher precedence than |.