rust/tests/ui/sort_by_key_reverse.rs

10 lines
249 B
Rust
Raw Normal View History

// run-rustfix
2020-05-14 17:06:05 -05:00
#![warn(clippy::sort_by_key_reverse)]
fn main() {
let mut vec: Vec<isize> = vec![3, 6, 1, 2, 5];
vec.sort_by(|a, b| b.cmp(a));
vec.sort_by(|a, b| (b + 5).abs().cmp(&(a+5).abs()));
vec.sort_by(|a, b| (-b).cmp(&-a));
2020-05-14 17:06:05 -05:00
}