diff --git a/.gitignore b/.gitignore index 253d85bd..534453bc 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ rust-project.json .idea .vscode *.iml +*.o diff --git a/exercises/clippy/clippy1.rs b/exercises/clippy/clippy1.rs index c5f84a9c..bad46891 100644 --- a/exercises/clippy/clippy1.rs +++ b/exercises/clippy/clippy1.rs @@ -4,7 +4,7 @@ // // For these exercises the code will fail to compile when there are clippy warnings // check clippy's suggestions from the output to solve the exercise. -// Execute `rustlings hint clippy1` for hints :) +// Execute `rustlings hint clippy1` or use the `hint` watch subcommand for a hint. // I AM NOT DONE diff --git a/exercises/clippy/clippy2.rs b/exercises/clippy/clippy2.rs index 37af9ed0..dac40dbe 100644 --- a/exercises/clippy/clippy2.rs +++ b/exercises/clippy/clippy2.rs @@ -1,5 +1,5 @@ // clippy2.rs -// Make me compile! Execute `rustlings hint clippy2` for hints :) +// Execute `rustlings hint clippy2` or use the `hint` watch subcommand for a hint. // I AM NOT DONE diff --git a/exercises/clippy/clippy3.rs b/exercises/clippy/clippy3.rs new file mode 100644 index 00000000..13733c0b --- /dev/null +++ b/exercises/clippy/clippy3.rs @@ -0,0 +1,26 @@ +// clippy3.rs +// Here's a couple more easy Clippy fixes, so you can see its utility. + +#[allow(unused_variables, unused_assignments)] +fn main() { + let my_option: Option<()> = None; + if my_option.is_none() { + my_option.unwrap(); + } + + let my_arr = &[ + -1, -2, -3 + -4, -5, -6 + ]; + println!("My array! Here it is: {:?}", my_arr); + + let my_empty_vec = vec![1, 2, 3, 4, 5].resize(0, 5); + println!("This Vec is empty, see? {:?}", my_empty_vec); + + let mut value_a = 45; + let mut value_b = 66; + // Let's swap these two! + value_a = value_b; + value_b = value_a; + println!("value a: {}; value b: {}", value_a, value_b); +} diff --git a/info.toml b/info.toml index 95674955..3c37f95b 100644 --- a/info.toml +++ b/info.toml @@ -989,6 +989,12 @@ mode = "clippy" hint = """ `for` loops over Option values are more clearly expressed as an `if let`""" +[[exercises]] +name = "clippy3" +path = "exercises/clippy/clippy3.rs" +mode = "clippy" +hint = "No hints this time!" + # TYPE CONVERSIONS [[exercises]]