Rust

Rust

By DeepSource

Found comparison with NaN RS-E1012

Bug risk
Autofix

Comparing a floating point with NaN using == or != is redundant. NaN cannot be compared to anything, not even itself. Use .is_nan() instead.

Bad practice

if x != f32::NAN {
    // ...
}

Recommended

if !x.is_nan() {
    // ...
}