RS.CLIPPY.UNNECESSARY_RESULT_MAP_OR_ELSE
Making no use of the \"map closure\" when calling `.map_or_else(|err| handle_error(err), |n| n)`
This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: unnecessary_result_map_or_else. Copyright ©2025 The Rust Team. All rights reserved.
What it does
Checks for usage of .map_or_else() "map closure" for Result type.
Why is this bad?
This can be written more concisely by using unwrap_or_else().
Example
let x: Result<u32, ()> = Ok(0);
let y = x.map_or_else(|err| handle_error(err), |n| n);
Use instead:
let x: Result<u32, ()> = Ok(0);
let y = x.unwrap_or_else(|err| handle_error(err));