]> git.lizzy.rs Git - rust.git/blob - tests/ui/min_max.rs
Auto merge of #68717 - petrochenkov:stabexpat, r=varkor
[rust.git] / tests / ui / min_max.rs
1 #![warn(clippy::all)]
2
3 use std::cmp::max as my_max;
4 use std::cmp::min as my_min;
5 use std::cmp::{max, min};
6
7 const LARGE: usize = 3;
8
9 fn main() {
10     let x;
11     x = 2usize;
12     min(1, max(3, x));
13     min(max(3, x), 1);
14     max(min(x, 1), 3);
15     max(3, min(x, 1));
16
17     my_max(3, my_min(x, 1));
18
19     min(3, max(1, x)); // ok, could be 1, 2 or 3 depending on x
20
21     min(1, max(LARGE, x)); // no error, we don't lookup consts here
22
23     let y = 2isize;
24     min(max(y, -1), 3);
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 }