fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

master
1.3 KiB48 linesraw
1#![allow(unused)]
2#![warn(clippy::manual_range_patterns)]
3#![feature(exclusive_range_pattern)]
4
5fn main() {
6    let f = 6;
7
8    let _ = matches!(f, 1..=10);
9    let _ = matches!(f, 1..=10);
10    let _ = matches!(f, 4 | 2 | 3 | 1 | 5 | 6 | 9 | 8 | 10); // 7 is missing
11    let _ = matches!(f, | 4);
12    let _ = matches!(f, 4 | 5);
13    let _ = matches!(f, 1 | 2147483647);
14    let _ = matches!(f, 0 | 2147483647);
15    let _ = matches!(f, -2147483647 | 2147483647);
16    let _ = matches!(f, 1..=4);
17    let _ = matches!(f, 1..4);
18    let _ = matches!(f, 1..=48324729);
19    let _ = matches!(f, 0..=48324730);
20    let _ = matches!(f, 0..=3);
21    #[allow(clippy::match_like_matches_macro)]
22    let _ = match f {
23        1..=10 => true,
24        _ => false,
25    };
26    let _ = matches!(f, -5..=3);
27    let _ = matches!(f, -1 | -5 | 3 | -2 | -4 | -3 | 0 | 1); // 2 is missing
28    let _ = matches!(f, -1_000_001..=1_000_001);
29    let _ = matches!(f, -1_000_000..=1_000_000 | -1_000_001 | 1_000_002);
30
31    matches!(f, 0x00..=0x03);
32    matches!(f, 0x00..=0x07);
33    matches!(f, -0x09..=0x00);
34
35    matches!(f, 0..=5);
36    matches!(f, 0..5);
37
38    matches!(f, 0..10);
39    matches!(f, 0..=10);
40    matches!(f, 0..=10);
41
42    macro_rules! mac {
43        ($e:expr) => {
44            matches!($e, 1..=10)
45        };
46    }
47    mac!(f);
48}