blob: 5de8fe8cdd7b0e128aca9f2502d1906414f6f4bc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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(())
}
|