Summary
manual_filter will work for the following:
match v {
Some(n) => {
if n > 10 {
Some(n)
} else {
None
}
}
None => None,
}
However, if we change Some(n) to Some(n + 1), it will not. For this case, the preferable behavior might be suggesting to use filter_map, i.e. Option::and_then instead.
Lint Name
manual_filter
Reproducer
I tried this code:
fn maunal_filter_and_then(v: Option<usize>) -> Option<usize> {
match v {
Some(n) => {
if n > 10 {
Some(n + 1)
} else {
None
}
}
None => None,
}
}
I expected to see this happen:
Lint on the match
Instead, this happened:
Nothing
Version
rustc 1.96.0-nightly (ac7f9ec7d 2026-03-20)
binary: rustc
commit-hash: ac7f9ec7da74d37fd28667c86bf117a39ba5b02a
commit-date: 2026-03-20
host: x86_64-unknown-linux-gnu
release: 1.96.0-nightly
LLVM version: 22.1.0
Summary
manual_filterwill work for the following:However, if we change
Some(n)toSome(n + 1), it will not. For this case, the preferable behavior might be suggesting to usefilter_map, i.e.Option::and_theninstead.Lint Name
manual_filter
Reproducer
I tried this code:
I expected to see this happen:
Lint on the match
Instead, this happened:
Nothing
Version