complete: clippy

This commit is contained in:
seth 2021-06-25 15:22:02 +08:00
parent e67dafa971
commit 4a08fff2b8
2 changed files with 3 additions and 6 deletions
exercises/clippy

View file

@ -6,12 +6,11 @@
// check clippy's suggestions from the output to solve the exercise. // check clippy's suggestions from the output to solve the exercise.
// Execute `rustlings hint clippy1` for hints :) // Execute `rustlings hint clippy1` for hints :)
// I AM NOT DONE
fn main() { fn main() {
let error_margin = f64::EPSILON;
let x = 1.2331f64; let x = 1.2331f64;
let y = 1.2332f64; let y = 1.2332f64;
if y != x { if (y - x).abs() > error_margin {
println!("Success!"); println!("Success!");
} }
} }

View file

@ -1,12 +1,10 @@
// clippy2.rs // clippy2.rs
// Make me compile! Execute `rustlings hint clippy2` for hints :) // Make me compile! Execute `rustlings hint clippy2` for hints :)
// I AM NOT DONE
fn main() { fn main() {
let mut res = 42; let mut res = 42;
let option = Some(12); let option = Some(12);
for x in option { if let Some(x) = option {
res += x; res += x;
} }
println!("{}", res); println!("{}", res);