summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--exercises/clippy/clippy1.rs2
-rw-r--r--exercises/clippy/clippy2.rs2
-rw-r--r--exercises/clippy/clippy3.rs26
-rw-r--r--info.toml6
5 files changed, 35 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore
index 253d85b..534453b 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 c5f84a9..bad4689 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 37af9ed..dac40db 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 0000000..13733c0
--- /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 9567495..3c37f95 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]]