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