rustlings/exercises/22_clippy/clippy3.rs

28 lines
732 B
Rust
Raw Permalink Normal View History

2024-10-28 20:46:17 +00:00
// 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<()> = None;
if my_option.is_none() {
2024-11-09 11:43:57 +00:00
println!("{:?}", my_option);
2024-10-28 20:46:17 +00:00
}
let my_arr = &[
2024-11-09 11:43:57 +00:00
-1, -2, -3,
2024-10-28 20:46:17 +00:00
-4, -5, -6
];
println!("My array! Here it is: {my_arr:?}");
2024-11-09 11:43:57 +00:00
let mut my_empty_vec = vec![1, 2, 3, 4, 5];
my_empty_vec.clear();
2024-10-28 20:46:17 +00:00
println!("This Vec is empty, see? {my_empty_vec:?}");
let mut value_a = 45;
let mut value_b = 66;
// Let's swap these two!
2024-11-09 11:43:57 +00:00
std::mem::swap(&mut value_a, &mut value_b);
2024-10-28 20:46:17 +00:00
println!("value a: {value_a}; value b: {value_b}");
}