RS.CLIPPY.SINGLE_OPTION_MAP
Checks for functions with method calls to `.map(_)` on an arg of type `Option` as the outermost expression.
This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: single_option_map. Copyright ©2025 The Rust Team. All rights reserved.
What it does
Checks for functions with method calls to .map(_) on an arg
of type Option as the outermost expression.
Why is this bad?
Taking and returning an Option<T> may require additional
Some(_) and unwrap if all you have is a T.
Example
fn double(param: Option<u32>) -> Option<u32> {
param.map(|x| x * 2)
}
Use instead:
fn double(param: u32) -> u32 {
param * 2
}