]> git.lizzy.rs Git - rust.git/blob - tests/ui/match/guards.rs
Auto merge of #106812 - oli-obk:output_filenames, r=petrochenkov
[rust.git] / tests / ui / match / guards.rs
1 // run-pass
2
3 #![allow(non_shorthand_field_patterns)]
4
5 #[derive(Copy, Clone)]
6 struct Pair { x: isize, y: isize }
7
8 pub fn main() {
9     let a: isize =
10         match 10 { x if x < 7 => { 1 } x if x < 11 => { 2 } 10 => { 3 } _ => { 4 } };
11     assert_eq!(a, 2);
12
13     let b: isize =
14         match (Pair {x: 10, y: 20}) {
15           x if x.x < 5 && x.y < 5 => { 1 }
16           Pair {x: x, y: y} if x == 10 && y == 20 => { 2 }
17           Pair {x: _x, y: _y} => { 3 }
18         };
19     assert_eq!(b, 2);
20 }