mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-12-30 06:53:27 +00:00
24 lines
415 B
Rust
24 lines
415 B
Rust
|
// run-rustfix
|
||
|
|
||
|
#![warn(clippy::comparison_to_empty)]
|
||
|
|
||
|
fn main() {
|
||
|
// Disallow comparisons to empty
|
||
|
let s = String::new();
|
||
|
let _ = s == "";
|
||
|
let _ = s != "";
|
||
|
|
||
|
let v = vec![0];
|
||
|
let _ = v == [];
|
||
|
let _ = v != [];
|
||
|
|
||
|
// Allow comparisons to non-empty
|
||
|
let s = String::new();
|
||
|
let _ = s == " ";
|
||
|
let _ = s != " ";
|
||
|
|
||
|
let v = vec![0];
|
||
|
let _ = v == [0];
|
||
|
let _ = v != [0];
|
||
|
}
|