Skip to content

Commit 5a0db73

Browse files
authored
Merge pull request #12 from davidlattimore/dir-entry-is-dir
Use file types returned by read_dir rather than requerying path
2 parents 1912f14 + 9a46cb3 commit 5a0db73

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/main.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ fn main() {
266266

267267
let target_rd = target_rd
268268
.filter_map(|it| it.ok())
269-
.filter_map(|it| it.path().is_dir().then(|| it.path()));
269+
.filter_map(|it| it.file_type().is_ok_and(|t| t.is_dir()).then(|| it.path()));
270270

271271
for target_subdir in target_rd {
272272
let files = match target_subdir.read_dir() {
@@ -281,7 +281,7 @@ fn main() {
281281

282282
let files = files
283283
.filter_map(|it| it.ok())
284-
.filter_map(|it| it.path().is_file().then(|| it.path()));
284+
.filter_map(|it| it.file_type().is_ok_and(|t| t.is_file()).then(|| it.path()));
285285

286286
for exe_file_path in files.filter(|file| is_executable(file)) {
287287
let new_exe_file_path = project_executables_path
@@ -400,8 +400,10 @@ fn find_cargo_projects_task(job: Job, results: Sender<ProjectDir>, args: &AppArg
400400
};
401401

402402
let (dirs, files): (Vec<_>, Vec<_>) = read_dir
403-
.filter_map(|it| it.ok().map(|it| it.path()))
404-
.partition(|it| it.is_dir());
403+
.filter_map(|it| it.ok())
404+
.partition(|it| it.file_type().is_ok_and(|t| t.is_dir()));
405+
let dirs: Vec<_> = dirs.iter().map(|it| it.path()).collect();
406+
let files: Vec<_> = files.iter().map(|it| it.path()).collect();
405407

406408
let has_cargo_toml = files
407409
.iter()

0 commit comments

Comments
 (0)