Add test.
This commit is contained in:
parent
2677a4ef02
commit
3a788452e2
23
tests/ui/filetype_is_file.rs
Normal file
23
tests/ui/filetype_is_file.rs
Normal file
@ -0,0 +1,23 @@
|
||||
#![warn(clippy::filetype_is_file)]
|
||||
|
||||
fn main() -> std::io::Result<()> {
|
||||
use std::fs;
|
||||
use std::ops::BitOr;
|
||||
|
||||
// !filetype.is_dir()
|
||||
if fs::metadata("foo.txt")?.file_type().is_file() {
|
||||
// read file
|
||||
}
|
||||
|
||||
// positive of filetype.is_dir()
|
||||
if !fs::metadata("foo.txt")?.file_type().is_file() {
|
||||
// handle dir
|
||||
}
|
||||
|
||||
// false positive of filetype.is_dir()
|
||||
if !fs::metadata("foo.txt")?.file_type().is_file().bitor(true) {
|
||||
// ...
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user