Skip to content

Commit

Permalink
Fix a clippy "unnecessary closure" warning
Browse files Browse the repository at this point in the history
Clippy 1.59 beta says:

error: unnecessary closure used to substitute value for `Option::None`
   --> src/properties.rs:119:22
    |
119 |           let offset = reply
    |  ______________________^
120 | |             .value
121 | |             .iter()
122 | |             .position(|&v| v == 0)
123 | |             .unwrap_or_else(|| reply.value.len());
    | |_________________________________________________^
    |
    = note: `-D clippy::unnecessary-lazy-evaluations` implied by `-D warnings`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_lazy_evaluations
help: use `unwrap_or` instead
    |
119 ~         let offset = reply
120 +             .value
121 +             .iter()
122 ~             .position(|&v| v == 0).unwrap_or(reply.value.len());
    |

Signed-off-by: Uli Schlachter <[email protected]>
  • Loading branch information
psychon committed Jan 14, 2022
1 parent af281c5 commit 14d7f4d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ impl WmClass {
.value
.iter()
.position(|&v| v == 0)
.unwrap_or_else(|| reply.value.len());
.unwrap_or(reply.value.len());
Ok(WmClass(reply, offset))
}

Expand Down

0 comments on commit 14d7f4d

Please sign in to comment.