mirror of
https://github.com/ArthurDanjou/rustlings.git
synced 2026-02-05 06:07:50 +01:00
Add initial solution files for Rustlings exercises and quizzes
- Created empty solution files for various exercises in strings, modules, hashmaps, options, error handling, generics, traits, lifetimes, tests, iterators, smart pointers, threads, macros, clippy, conversions, and quizzes. - Each solution file contains a main function with a comment indicating that it will be automatically filled after completing the exercise. - Added a README.md file to provide information about the solutions and their purpose.
This commit is contained in:
28
exercises/22_clippy/clippy3.rs
Normal file
28
exercises/22_clippy/clippy3.rs
Normal file
@@ -0,0 +1,28 @@
|
||||
// Here are some more easy Clippy fixes so you can see its utility 📎
|
||||
// TODO: Fix all the Clippy lints.
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[allow(unused_variables, unused_assignments)]
|
||||
fn main() {
|
||||
let my_option: Option<&str> = None;
|
||||
// Assume that you don't know the value of `my_option`.
|
||||
// In the case of `Some`, we want to print its value.
|
||||
if let Some(val) = my_option {
|
||||
println!("{}", val);
|
||||
}
|
||||
|
||||
let my_arr = &[
|
||||
-1, -2, -3,
|
||||
-4, -5, -6
|
||||
];
|
||||
println!("My array! Here it is: {my_arr:?}");
|
||||
|
||||
let my_empty_vec: Vec<i32> = vec![];
|
||||
println!("This Vec is empty, see? {my_empty_vec:?}");
|
||||
|
||||
let mut value_a = 45;
|
||||
let mut value_b = 66;
|
||||
// Let's swap these two!
|
||||
std::mem::swap(&mut value_a, &mut value_b);
|
||||
println!("value a: {value_a}; value b: {value_b}");
|
||||
}
|
||||
Reference in New Issue
Block a user