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