The lint triggers even when both sides of the conditional use the same variable and consume it.
Lint Name
option_if_let_else
Reproducer
I tried this code:
if let Ok(data) = str::from_utf8(&loaded) {
ExportData::Human(data.into())
} else {
ExportData::Bytes(loaded.into_inner())
}
I saw this happen:
str::from_utf8(&loaded).map_or_else(|_| ExportData::Bytes(loaded.into_inner()), |data| ExportData::Human(data.into()))
// Doesn't compile: cannot move out of `loaded` because it is borrowed [E0505] move out of `loaded` occurs here
Summary
The lint triggers even when both sides of the conditional use the same variable and consume it.
Lint Name
option_if_let_else
Reproducer
I tried this code:
I saw this happen:
Version
Additional Labels
No response