Open
Description
Summary
No response
Reproducer
I tried this code:
let metoame = tauste
.iter()
.filter(|(metoa, _, _)| {
!metoa.is_empty() && !toadua.lines().any(|toa| toa == metoa.join(""))
})
.map(|(metoa, lujvo, def)| (metoa.join(""), lujvo, def))
.map(|(metoa, lujvo, def)| (if let Some(t) = metoa.strip_prefix('\'') {t.to_string()}else{metoa}, lujvo, def))
.collect_vec();
I expected to see this happen: Unknown
Instead, this happened:
warning: use Option::map_or instead of an if let/else
--> src\main.rs:103:37
|
103 | .map(|(metoa, lujvo, def)| (if let Some(t) = metoa.strip_prefix('\'') {t.to_string()}else{metoa}, lujvo, def))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `metoa.strip_prefix('\'').map_or(metoa, |t| t.to_string())`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#option_if_let_else
= note: `-W clippy::option-if-let-else` implied by `-W clippy::nursery`
= help: to override `-W clippy::nursery` add `#[allow(clippy::option_if_let_else)]`
Accepting this suggestion yields an [E0505]
:
error[E0505]: cannot move out of `metoa` because it is borrowed
--> src\main.rs:103:69
|
103 | .map(|(metoa, lujvo, def)| (metoa.strip_prefix('\'').map_or(metoa, |t| t.to_string()), lujvo, def))
| ----- ----- ------ ^^^^^ move out of `metoa` occurs here
| | | |
| | | borrow later used by call
| | borrow of `metoa` occurs here
| binding `metoa` declared here
Version
rustc 1.88.0-nightly (00095b3da 2025-04-03)
binary: rustc
commit-hash: 00095b3da4f23d9b3e7a809ac6a4e2b2530df84c
commit-date: 2025-04-03
host: x86_64-pc-windows-msvc
release: 1.88.0-nightly
LLVM version: 20.1.2
Additional Labels
@rustbot label +I-suggestion-causes-error