Skip to content

Commit 8cfedb1

Browse files
committed
feat(clippy): add clippy3
1 parent 7fc393b commit 8cfedb1

File tree

5 files changed

+35
-2
lines changed

5 files changed

+35
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ rust-project.json
99
.idea
1010
.vscode
1111
*.iml
12+
*.o

exercises/clippy/clippy1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//
55
// For these exercises the code will fail to compile when there are clippy warnings
66
// check clippy's suggestions from the output to solve the exercise.
7-
// Execute `rustlings hint clippy1` for hints :)
7+
// Execute `rustlings hint clippy1` or use the `hint` watch subcommand for a hint.
88

99
// I AM NOT DONE
1010

exercises/clippy/clippy2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// clippy2.rs
2-
// Make me compile! Execute `rustlings hint clippy2` for hints :)
2+
// Execute `rustlings hint clippy2` or use the `hint` watch subcommand for a hint.
33

44
// I AM NOT DONE
55

exercises/clippy/clippy3.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// clippy3.rs
2+
// Here's a couple more easy Clippy fixes, so you can see its utility.
3+
4+
#[allow(unused_variables, unused_assignments)]
5+
fn main() {
6+
let my_option: Option<()> = None;
7+
if my_option.is_none() {
8+
my_option.unwrap();
9+
}
10+
11+
let my_arr = &[
12+
-1, -2, -3
13+
-4, -5, -6
14+
];
15+
println!("My array! Here it is: {:?}", my_arr);
16+
17+
let my_empty_vec = vec![1, 2, 3, 4, 5].resize(0, 5);
18+
println!("This Vec is empty, see? {:?}", my_empty_vec);
19+
20+
let mut value_a = 45;
21+
let mut value_b = 66;
22+
// Let's swap these two!
23+
value_a = value_b;
24+
value_b = value_a;
25+
println!("value a: {}; value b: {}", value_a, value_b);
26+
}

info.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -989,6 +989,12 @@ mode = "clippy"
989989
hint = """
990990
`for` loops over Option values are more clearly expressed as an `if let`"""
991991

992+
[[exercises]]
993+
name = "clippy3"
994+
path = "exercises/clippy/clippy3.rs"
995+
mode = "clippy"
996+
hint = "No hints this time!"
997+
992998
# TYPE CONVERSIONS
993999

9941000
[[exercises]]

0 commit comments

Comments
 (0)