2018-08-30 12:18:55 +00:00
|
|
|
//@ run-pass
|
2017-01-10 21:13:53 +00:00
|
|
|
#![feature(exclusive_range_pattern)]
|
2012-12-11 01:32:48 +00:00
|
|
|
|
2013-02-02 03:43:17 +00:00
|
|
|
pub fn main() {
|
2015-02-18 10:42:01 +00:00
|
|
|
match 5_usize {
|
2018-05-29 02:42:11 +00:00
|
|
|
1_usize..=5_usize => {}
|
2014-10-09 19:17:22 +00:00
|
|
|
_ => panic!("should match range"),
|
2011-09-28 19:07:33 +00:00
|
|
|
}
|
2017-01-10 21:13:53 +00:00
|
|
|
match 1_usize {
|
|
|
|
1_usize..5_usize => {}
|
|
|
|
_ => panic!("should match range start"),
|
|
|
|
}
|
2015-02-18 10:42:01 +00:00
|
|
|
match 5_usize {
|
2018-05-29 02:42:11 +00:00
|
|
|
6_usize..=7_usize => panic!("shouldn't match range"),
|
2012-08-04 02:59:04 +00:00
|
|
|
_ => {}
|
2011-09-28 19:07:33 +00:00
|
|
|
}
|
2017-01-10 21:13:53 +00:00
|
|
|
match 7_usize {
|
|
|
|
6_usize..7_usize => panic!("shouldn't match range end"),
|
|
|
|
_ => {},
|
|
|
|
}
|
2015-02-18 10:42:01 +00:00
|
|
|
match 5_usize {
|
|
|
|
1_usize => panic!("should match non-first range"),
|
2018-05-29 02:42:11 +00:00
|
|
|
2_usize..=6_usize => {}
|
2014-10-09 19:17:22 +00:00
|
|
|
_ => panic!("math is broken")
|
2011-09-28 19:07:33 +00:00
|
|
|
}
|
2012-08-06 19:34:08 +00:00
|
|
|
match 'c' {
|
2018-05-29 02:42:11 +00:00
|
|
|
'a'..='z' => {}
|
2018-08-19 13:30:23 +00:00
|
|
|
_ => panic!("should support char ranges")
|
2011-09-28 19:07:33 +00:00
|
|
|
}
|
2015-01-25 21:05:03 +00:00
|
|
|
match -3 {
|
2018-05-29 02:42:11 +00:00
|
|
|
-7..=5 => {}
|
2014-10-09 19:17:22 +00:00
|
|
|
_ => panic!("should match signed range")
|
2011-09-28 19:07:33 +00:00
|
|
|
}
|
2014-06-27 19:30:25 +00:00
|
|
|
match 3.0f64 {
|
2018-05-29 02:42:11 +00:00
|
|
|
1.0..=5.0 => {}
|
2014-10-09 19:17:22 +00:00
|
|
|
_ => panic!("should match float range")
|
2011-09-28 19:07:33 +00:00
|
|
|
}
|
2014-06-27 19:30:25 +00:00
|
|
|
match -1.5f64 {
|
2018-05-29 02:42:11 +00:00
|
|
|
-3.6..=3.6 => {}
|
2014-10-09 19:17:22 +00:00
|
|
|
_ => panic!("should match negative float range")
|
2011-09-28 19:07:33 +00:00
|
|
|
}
|
2017-01-10 21:13:53 +00:00
|
|
|
match 3.5 {
|
|
|
|
0.0..3.5 => panic!("should not match the range end"),
|
|
|
|
_ => {},
|
|
|
|
}
|
|
|
|
match 0.0 {
|
|
|
|
0.0..3.5 => {},
|
|
|
|
_ => panic!("should match the range start"),
|
|
|
|
}
|
2011-09-28 19:07:33 +00:00
|
|
|
}
|