Skip to main content

INVALID_NAN_COMPARISONS

Static INVALID_NAN_COMPARISONS 

Source
static INVALID_NAN_COMPARISONS: &Lint
Expand description

The invalid_nan_comparisons lint checks comparisons with the NAN constants of f16, f32, f64, and f128.

§Example

let a = 2.3f32;
if a == f32::NAN {}

{{produces}}

§Explanation

NaN compares unequal to every floating-point value, including itself. Use the is_nan method to check whether a value is NaN.