2019-07-27 00:54:25 +03:00
|
|
|
// run-pass
|
|
|
|
|
2018-09-14 12:20:28 +02:00
|
|
|
#![allow(non_shorthand_field_patterns)]
|
2015-03-22 13:13:15 -07:00
|
|
|
|
2015-03-30 09:38:27 -04:00
|
|
|
#[derive(Copy, Clone)]
|
2015-03-25 17:06:52 -07:00
|
|
|
struct Pair { x: isize, y: isize }
|
2013-01-25 22:46:32 -08:00
|
|
|
|
2013-02-01 19:43:17 -08:00
|
|
|
pub fn main() {
|
2015-03-25 17:06:52 -07:00
|
|
|
let a: isize =
|
2015-01-25 22:05:03 +01:00
|
|
|
match 10 { x if x < 7 => { 1 } x if x < 11 => { 2 } 10 => { 3 } _ => { 4 } };
|
2013-05-18 22:02:45 -04:00
|
|
|
assert_eq!(a, 2);
|
2011-08-22 14:38:48 +02:00
|
|
|
|
2015-03-25 17:06:52 -07:00
|
|
|
let b: isize =
|
2014-06-13 19:09:12 -07:00
|
|
|
match (Pair {x: 10, y: 20}) {
|
2015-01-25 22:05:03 +01:00
|
|
|
x if x.x < 5 && x.y < 5 => { 1 }
|
|
|
|
Pair {x: x, y: y} if x == 10 && y == 20 => { 2 }
|
|
|
|
Pair {x: _x, y: _y} => { 3 }
|
2011-09-02 15:34:58 -07:00
|
|
|
};
|
2013-05-18 22:02:45 -04:00
|
|
|
assert_eq!(b, 2);
|
2011-08-22 14:38:48 +02:00
|
|
|
}
|