mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-04 12:44:40 +00:00
25 lines
468 B
Rust
25 lines
468 B
Rust
//@run-rustfix
|
|
|
|
#![warn(clippy::comparison_to_empty)]
|
|
#![allow(clippy::useless_vec)]
|
|
|
|
fn main() {
|
|
// Disallow comparisons to empty
|
|
let s = String::new();
|
|
let _ = s.is_empty();
|
|
let _ = !s.is_empty();
|
|
|
|
let v = vec![0];
|
|
let _ = v.is_empty();
|
|
let _ = !v.is_empty();
|
|
|
|
// Allow comparisons to non-empty
|
|
let s = String::new();
|
|
let _ = s == " ";
|
|
let _ = s != " ";
|
|
|
|
let v = vec![0];
|
|
let _ = v == [0];
|
|
let _ = v != [0];
|
|
}
|