]> git.proxmox.com Git - rustc.git/blob - src/test/ui/guards.rs
New upstream version 1.49.0+dfsg1
[rustc.git] / src / test / ui / 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 }