3 #![feature(custom_inner_attributes)]
4 #![warn(clippy::manual_range_contains)]
6 #![allow(clippy::no_effect)]
7 #![allow(clippy::short_circuit_statement)]
8 #![allow(clippy::unnecessary_operation)]
13 // order shouldn't matter
15 (21..42).contains(&x);
16 (1..100).contains(&x);
18 // also with inclusive ranges
19 (9..=99).contains(&x);
20 (1..=33).contains(&x);
21 (1..=999).contains(&x);
24 !(8..12).contains(&x);
25 !(21..42).contains(&x);
26 !(1..100).contains(&x);
28 // also with the outside of inclusive ranges
29 !(9..=99).contains(&x);
30 !(1..=33).contains(&x);
31 !(1..=999).contains(&x);
33 // not a range.contains
34 x > 8 && x < 12; // lower bound not inclusive
35 x < 8 && x <= 12; // same direction
36 x >= 12 && 12 >= x; // same bounds
37 x < 8 && x > 12; // wrong direction
46 (0. ..1.).contains(&y);
47 !(0. ..=1.).contains(&y);
49 // handle negatives #8721
50 (-10..=10).contains(&x);
52 (-3. ..=3.).contains(&y);
57 (0..=10).contains(&x) && (0..=10).contains(&z);
58 !(0..10).contains(&x) || !(0..10).contains(&z);
59 // Make sure operators in parens don't give a breaking suggestion
60 ((x % 2 == 0) || (x < 0)) || (x >= 10);
64 pub const fn in_range(a: i32) -> bool {
69 #![clippy::msrv = "1.34"]
76 #![clippy::msrv = "1.35"]