Rust logoRust/
RS-C1008

Found block expression in `if` conditionRS-C1008

Minor severityMinor
Anti-pattern categoryAnti-pattern

Using block expressions as if conditions can confuse readers of this code.

Consider creating a let binding.

Bad practice

// useless block
if { true } { /* ... */ }

// hard-to-read block
if { let x = a(); b } { /* ... */ }
// remove useless braces
if true { /* ... */ }

// create an explicit binding
let res = { 
    let x = a();
    b
};
if res { /* ... */ }