mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 21:23:56 +00:00
Add test.
This commit is contained in:
parent
2677a4ef02
commit
3a788452e2
1 changed files with 23 additions and 0 deletions
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…
Reference in a new issue