]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui/filetype_is_file.rs
Rollup merge of #102581 - jyn514:src-detection, r=Mark-Simulacrum
[rust.git] / src / tools / clippy / tests / ui / filetype_is_file.rs
1 #![warn(clippy::filetype_is_file)]
2
3 fn main() -> std::io::Result<()> {
4     use std::fs;
5     use std::ops::BitOr;
6
7     // !filetype.is_dir()
8     if fs::metadata("foo.txt")?.file_type().is_file() {
9         // read file
10     }
11
12     // positive of filetype.is_dir()
13     if !fs::metadata("foo.txt")?.file_type().is_file() {
14         // handle dir
15     }
16
17     // false positive of filetype.is_dir()
18     if !fs::metadata("foo.txt")?.file_type().is_file().bitor(true) {
19         // ...
20     }
21
22     Ok(())
23 }