You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Checking playground v0.0.1 (/playground)
warning: use Option::map_or instead of an if let/else
--> src/main.rs:7:5
|
7 | / if let Some(b2) = optional {
8 | | b1.0 + &b2.0
9 | | } else {
10 | | b1.0
11 | | }
| |_____^ help: try: `optional.map_or(b1.0, |b2| b1.0 + &b2.0)`
|
note: the lint level is defined here
--> src/main.rs:1:9
|
1 | #![warn(clippy::pedantic)]
| ^^^^^^^^^^^^^^^^
= note: `#[warn(clippy::option_if_let_else)]` implied by `#[warn(clippy::pedantic)]`
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#option_if_let_else
warning: 1 warning emitted
Finished dev [unoptimized + debuginfo] target(s) in 0.32s
But when I apply clippy's suggestion, borrow checking rightly rejects by code because both closures try to move the value of b1 (and the compiler cannot know that only one closure will ever be called`.
I tried this code:
Which gives the following cargo clippy output
But when I apply clippy's suggestion, borrow checking rightly rejects by code because both closures try to move the value of
b1
(and the compiler cannot know that only one closure will ever be called`.Meta
clippy 0.0.212 (2020-09-16 285fc7d)
: (from playground)rustc 1.46.0 stable
or1.48.0-nightly (2020-09-16 285fc7d704fcdd7b2a37)
: (from playground)The text was updated successfully, but these errors were encountered: