We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
{f32, f64}::is_finite
{f32, f64}::is_infinite
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Detects manual implementations of these functions and suggests replacing them with a call to that function.
float_manual_finite/float_manual_infinite
style, pedantic
is_infinite
fn double(float: f32) -> f32 { if float == f32::INFINITY || float == f32::NEG_INFINITY { println!("is infinite"); } float * 2.0 } fn main() { dbg!(double(6.63E-34)); }
Could be written as:
fn double(float: f32) -> f32 { if float.is_infinite() { println!("is infinite"); } float * 2.0 } fn main() { dbg!(double(6.63E-34)); }
fn double(float: f32) -> f32 { assert!(float != f32::INFINITY && float != f32::NEG_INFINITY); float * 2.0 } fn main() { dbg!(double(6.63E-34)); }
fn double(float: f32) -> f32 { assert!(float.is_finite()); float * 2.0 } fn main() { dbg!(double(6.63E-34)); }
The text was updated successfully, but these errors were encountered:
@rustbot claim
Sorry, something went wrong.
comparison_to_empty
if let
let
manual_is_infinite
manual_is_finite
8e261c0
Centri3
Successfully merging a pull request may close this issue.
What it does
Detects manual implementations of these functions and suggests replacing them with a call to that function.
Lint Name
float_manual_finite/float_manual_infinite
Category
style, pedantic
Advantage
is_infinite
, which suggests some future optimizationsDrawbacks
Example
Could be written as:
Could be written as:
The text was updated successfully, but these errors were encountered: