Skip to content

Commit

Permalink
Resolve map_unwrap_or pedantic clippy lint
Browse files Browse the repository at this point in the history
    error: called `map(<f>).unwrap_or(<a>)` on an `Option` value. This can be done more directly by calling `map_or(<a>, <f>)` instead
      --> tests/repo/mod.rs:73:8
       |
    73 |     if path.extension().map(|e| e != "rs").unwrap_or(true) {
       |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       |
       = note: `-D clippy::map-unwrap-or` implied by `-D clippy::pedantic`
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#map_unwrap_or
    help: use `map_or(<a>, <f>)` instead
       |
    73 -     if path.extension().map(|e| e != "rs").unwrap_or(true) {
    73 +     if path.extension().map_or(true, |e| e != "rs") {
       |
  • Loading branch information
dtolnay committed Sep 30, 2021
1 parent d9a6d8f commit 2de9ea7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tests/repo/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::if_then_panic, clippy::map_unwrap_or)]
#![allow(clippy::if_then_panic)]

mod progress;

Expand Down Expand Up @@ -70,7 +70,7 @@ pub fn base_dir_filter(entry: &DirEntry) -> bool {
if path.is_dir() {
return true; // otherwise walkdir does not visit the files
}
if path.extension().map(|e| e != "rs").unwrap_or(true) {
if path.extension().map_or(true, |e| e != "rs") {
return false;
}

Expand Down

0 comments on commit 2de9ea7

Please sign in to comment.