mirror of
https://github.com/notohh/rustlings.git
synced 2024-12-22 00:18:09 -05:00
feat(clippy): add clippy3
This commit is contained in:
parent
7fc393bed4
commit
8cfedb1673
5 changed files with 35 additions and 2 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -9,3 +9,4 @@ rust-project.json
|
|||
.idea
|
||||
.vscode
|
||||
*.iml
|
||||
*.o
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
26
exercises/clippy/clippy3.rs
Normal file
26
exercises/clippy/clippy3.rs
Normal file
|
@ -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);
|
||||
}
|
|
@ -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]]
|
||||
|
|
Loading…
Reference in a new issue