Rust

Rust

Made by DeepSource

Found block expression in if condition RS-C1008

Anti-pattern
Minor

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 } { /* ... */ }

Recommended

// remove useless braces
if true { /* ... */ }

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