Rust

Rust

Made by DeepSource

Found usage of then_some(..).unwrap_or(..) RS-C1015

Anti-pattern
Minor
Autofix

Using then_some(..).unwrap_or(..) obfuscates the comparison itself and reduces code readability. It can be better written as an if-else block.

Bad practice

fn foo() -> usize {
    (0 == 1).then_some(1).unwrap_or(0)
}

Recommended

fn foo() -> usize {
    if 0 == 1 { 1 } else { 0 }
}