2018-08-30 07:18:55 -05:00
|
|
|
// run-pass
|
2014-03-22 07:55:46 -05:00
|
|
|
|
|
|
|
pub fn main() {
|
2015-01-25 15:05:03 -06:00
|
|
|
let x = 1;
|
|
|
|
let y = 2;
|
2014-03-22 07:55:46 -05:00
|
|
|
|
2015-01-25 15:05:03 -06:00
|
|
|
assert_eq!(3, match (x, y) {
|
2014-03-22 07:55:46 -05:00
|
|
|
(1, 1) => 1,
|
|
|
|
(2, 2) => 2,
|
2018-05-28 21:42:11 -05:00
|
|
|
(1..=2, 2) => 3,
|
2014-03-22 07:55:46 -05:00
|
|
|
_ => 4,
|
|
|
|
});
|
|
|
|
|
|
|
|
// nested tuple
|
2015-01-25 15:05:03 -06:00
|
|
|
assert_eq!(3, match ((x, y),) {
|
2014-03-22 07:55:46 -05:00
|
|
|
((1, 1),) => 1,
|
|
|
|
((2, 2),) => 2,
|
2018-05-28 21:42:11 -05:00
|
|
|
((1..=2, 2),) => 3,
|
2014-03-22 07:55:46 -05:00
|
|
|
_ => 4,
|
|
|
|
});
|
|
|
|
}
|