]>
Commit | Line | Data |
---|---|---|
ea8adc8c | 1 | |
abe05a73 XL |
2 | |
3 | ||
ea8adc8c XL |
4 | #![warn(clippy)] |
5 | ||
6 | use std::cmp::{min, max}; | |
7 | use std::cmp::min as my_min; | |
8 | use std::cmp::max as my_max; | |
9 | ||
10 | const LARGE : usize = 3; | |
11 | ||
12 | fn main() { | |
13 | let x; | |
14 | x = 2usize; | |
15 | min(1, max(3, x)); | |
16 | min(max(3, x), 1); | |
17 | max(min(x, 1), 3); | |
18 | max(3, min(x, 1)); | |
19 | ||
20 | my_max(3, my_min(x, 1)); | |
21 | ||
22 | min(3, max(1, x)); // ok, could be 1, 2 or 3 depending on x | |
23 | ||
24 | min(1, max(LARGE, x)); // no error, we don't lookup consts here | |
25 | ||
26 | let s; | |
27 | s = "Hello"; | |
28 | ||
29 | min("Apple", max("Zoo", s)); | |
30 | max(min(s, "Apple"), "Zoo"); | |
31 | ||
32 | max("Apple", min(s, "Zoo")); // ok | |
33 | } |