matches: special message for this case

match &e { &Pat1 => {}, &Pat2 => {}, ... }

(inspired by dogfood fixes)
This commit is contained in:
Georg Brandl 2015-08-21 20:49:59 +02:00
parent 8f1a237493
commit 7580da306e
2 changed files with 20 additions and 13 deletions

View file

@ -53,6 +53,12 @@ fn ref_pats() {
&(v, 1) => println!("{}", v),
_ => println!("none"),
}
// special case: using & both in expr and pats
let w = Some(0);
match &w { //~ERROR you don't need to add `&` to both
&Some(v) => println!("{:?}", v),
&None => println!("none"),
}
}
fn main() {