From fb021d7ceff3f8b1d7cdb0c2bdd75ea07c0428d2 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Wed, 15 Mar 2023 17:46:36 -0400 Subject: 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` and that clippy should suggest rewriting to `map(...).unwrap_or(...)`/`map(...).unwrap_or_else(|| ...)` https://github.com/rust-lang/rfcs/issues/1025 --- cli/util/fs.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'cli/util') diff --git a/cli/util/fs.rs b/cli/util/fs.rs index 4ac57eac0..8167fd2e5 100644 --- a/cli/util/fs.rs +++ b/cli/util/fs.rs @@ -732,7 +732,8 @@ mod tests { path .file_name() .and_then(|f| f.to_str()) - .map_or(false, |f| !f.starts_with('.')) + .map(|f| !f.starts_with('.')) + .unwrap_or(false) }) .add_ignore_paths(&[ignore_dir_path]); @@ -847,7 +848,8 @@ mod tests { path .file_name() .and_then(|f| f.to_str()) - .map_or(false, |f| !f.starts_with('.')) + .map(|f| !f.starts_with('.')) + .unwrap_or(false) }; let result = collect_specifiers( -- cgit v1.2.3