summaryrefslogtreecommitdiff
path: root/ext/fs/lib.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2023-03-15 17:46:36 -0400
committerGitHub <noreply@github.com>2023-03-15 17:46:36 -0400
commitfb021d7ceff3f8b1d7cdb0c2bdd75ea07c0428d2 (patch)
tree09cb2bf87bba760b1abf706e0b8faedc9c368bbc /ext/fs/lib.rs
parentca51f4f6c058d16ac438ad75ac92e8954895f5aa (diff)
refactor: remove usages of `map_or` / `map_or_else` (#18212)
These methods are confusing because the arguments are backwards. I feel like they should have never been added to `Option<T>` and that clippy should suggest rewriting to `map(...).unwrap_or(...)`/`map(...).unwrap_or_else(|| ...)` https://github.com/rust-lang/rfcs/issues/1025
Diffstat (limited to 'ext/fs/lib.rs')
-rw-r--r--ext/fs/lib.rs18
1 files changed, 12 insertions, 6 deletions
diff --git a/ext/fs/lib.rs b/ext/fs/lib.rs
index 387241ee7..522dea3fb 100644
--- a/ext/fs/lib.rs
+++ b/ext/fs/lib.rs
@@ -1410,13 +1410,16 @@ where
name,
is_file: entry
.file_type()
- .map_or(false, |file_type| file_type.is_file()),
+ .map(|file_type| file_type.is_file())
+ .unwrap_or(false),
is_directory: entry
.file_type()
- .map_or(false, |file_type| file_type.is_dir()),
+ .map(|file_type| file_type.is_dir())
+ .unwrap_or(false),
is_symlink: entry
.file_type()
- .map_or(false, |file_type| file_type.is_symlink()),
+ .map(|file_type| file_type.is_symlink())
+ .unwrap_or(false),
})
} else {
None
@@ -1457,13 +1460,16 @@ where
name,
is_file: entry
.file_type()
- .map_or(false, |file_type| file_type.is_file()),
+ .map(|file_type| file_type.is_file())
+ .unwrap_or(false),
is_directory: entry
.file_type()
- .map_or(false, |file_type| file_type.is_dir()),
+ .map(|file_type| file_type.is_dir())
+ .unwrap_or(false),
is_symlink: entry
.file_type()
- .map_or(false, |file_type| file_type.is_symlink()),
+ .map(|file_type| file_type.is_symlink())
+ .unwrap_or(false),
})
} else {
None