RS.CLIPPY.OBFUSCATED_IF_ELSE
More clearly with `if .. else ..`
This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: obfuscated_if_else. Copyright ©2025 The Rust Team. All rights reserved.
What it does
Checks for unnecessary method chains that can be simplified into if .. else ...
Why is this bad?
This can be written more clearly with if .. else ..
Limitations
This lint currently only looks for usages of
.{then, then_some}(..).{unwrap_or, unwrap_or_else, unwrap_or_default}(..), but will be expanded
to account for similar patterns.
Example
let x = true;
x.then_some("a").unwrap_or("b");
Use instead:
let x = true;
if x { "a" } else { "b" };