Add test.

This commit is contained in:
xiongmao86 2020-01-02 11:37:32 +08:00
parent 2677a4ef02
commit 3a788452e2

View 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(())
}