initial commit
This commit is contained in:
7
clippy/Cargo.lock
generated
Normal file
7
clippy/Cargo.lock
generated
Normal file
@@ -0,0 +1,7 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "clippy3"
|
||||
version = "0.0.1"
|
||||
7
clippy/Cargo.toml
Normal file
7
clippy/Cargo.toml
Normal file
@@ -0,0 +1,7 @@
|
||||
[package]
|
||||
name = "clippy3"
|
||||
version = "0.0.1"
|
||||
edition = "2021"
|
||||
[[bin]]
|
||||
name = "clippy3"
|
||||
path = "clippy3.rs"
|
||||
10
clippy/README.md
Normal file
10
clippy/README.md
Normal file
@@ -0,0 +1,10 @@
|
||||
# Clippy
|
||||
|
||||
The Clippy tool is a collection of lints to analyze your code so you can catch common mistakes and improve your Rust code.
|
||||
|
||||
If you used the installation script for Rustlings, Clippy should be already installed.
|
||||
If not you can install it manually via `rustup component add clippy`.
|
||||
|
||||
## Further information
|
||||
|
||||
- [GitHub Repository](https://github.com/rust-lang/rust-clippy).
|
||||
27
clippy/clippy1.rs
Normal file
27
clippy/clippy1.rs
Normal file
@@ -0,0 +1,27 @@
|
||||
// clippy1.rs
|
||||
//
|
||||
// The Clippy tool is a collection of lints to analyze your code so you can
|
||||
// catch common mistakes and improve your Rust code.
|
||||
//
|
||||
// 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` or use the `hint` watch subcommand for a
|
||||
// hint.
|
||||
|
||||
// I AM DONE
|
||||
|
||||
use std::f32;
|
||||
|
||||
#[allow(clippy::approx_constant)]
|
||||
fn main() {
|
||||
let pi = 3.14f32;
|
||||
let radius = 5.00f32;
|
||||
|
||||
let area = pi * f32::powi(radius, 2);
|
||||
|
||||
println!(
|
||||
"The area of a circle with radius {:.2} is {:.5}!",
|
||||
radius, area
|
||||
)
|
||||
}
|
||||
16
clippy/clippy2.rs
Normal file
16
clippy/clippy2.rs
Normal file
@@ -0,0 +1,16 @@
|
||||
// clippy2.rs
|
||||
//
|
||||
// Execute `rustlings hint clippy2` or use the `hint` watch subcommand for a
|
||||
// hint.
|
||||
|
||||
// I AM DONE
|
||||
|
||||
#[allow(for_loops_over_fallibles)]
|
||||
fn main() {
|
||||
let mut res = 42;
|
||||
let option = Some(12);
|
||||
for x in option {
|
||||
res += x;
|
||||
}
|
||||
println!("{}", res);
|
||||
}
|
||||
31
clippy/clippy3.rs
Normal file
31
clippy/clippy3.rs
Normal file
@@ -0,0 +1,31 @@
|
||||
// clippy3.rs
|
||||
//
|
||||
// Here's a couple more easy Clippy fixes, so you can see its utility.
|
||||
// No hints.
|
||||
|
||||
// I AM DONE
|
||||
|
||||
#[allow(unused_variables, unused_assignments)]
|
||||
#[allow(clippy::panicking_unwrap)]
|
||||
#[allow(clippy::almost_swapped)]
|
||||
#[allow(clippy::unnecessary_literal_unwrap)]
|
||||
#[allow(clippy::let_unit_value)]
|
||||
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);
|
||||
}
|
||||
1
clippy/target/.rustc_info.json
Normal file
1
clippy/target/.rustc_info.json
Normal file
@@ -0,0 +1 @@
|
||||
{"rustc_fingerprint":11792070684003744821,"outputs":{"17471738939474973447":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n/home/minhradz/.rustup/toolchains/stable-x86_64-unknown-linux-gnu\noff\npacked\nunpacked\n___\nclippy\ndebug_assertions\nfeature=\"cargo-clippy\"\npanic=\"unwind\"\nproc_macro\ntarget_abi=\"\"\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"gnu\"\ntarget_family=\"unix\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"linux\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"unknown\"\nunix\n","stderr":""},"14478210374123597319":{"success":true,"status":"","code":0,"stdout":"rustc 1.79.0 (129f3b996 2024-06-10)\nbinary: rustc\ncommit-hash: 129f3b9964af4d4a709d1383930ade12dfe7c081\ncommit-date: 2024-06-10\nhost: x86_64-unknown-linux-gnu\nrelease: 1.79.0\nLLVM version: 18.1.7\n","stderr":""}},"successes":{}}
|
||||
3
clippy/target/CACHEDIR.TAG
Normal file
3
clippy/target/CACHEDIR.TAG
Normal file
@@ -0,0 +1,3 @@
|
||||
Signature: 8a477f597d28d172789f06886806bc55
|
||||
# This file is a cache directory tag created by cargo.
|
||||
# For information about cache directory tags see https://bford.info/cachedir/
|
||||
0
clippy/target/debug/.cargo-lock
Normal file
0
clippy/target/debug/.cargo-lock
Normal file
@@ -0,0 +1 @@
|
||||
9d78001aa0a9fe34
|
||||
@@ -0,0 +1 @@
|
||||
{"rustc":18217185010275080438,"features":"[]","declared_features":"","target":15082887096810505001,"profile":5601947868832436996,"path":2386747541556052359,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/clippy3-36457a3dd0101112/dep-bin-clippy3"}}],"rustflags":["-C","link-arg=-fuse-ld=/usr/bin/mold"],"metadata":7797948686568424061,"config":16520146531172537597,"compile_kind":0}
|
||||
Binary file not shown.
@@ -0,0 +1 @@
|
||||
This file has an mtime of when this was started.
|
||||
9
clippy/target/debug/deps/clippy3-36457a3dd0101112.d
Normal file
9
clippy/target/debug/deps/clippy3-36457a3dd0101112.d
Normal file
@@ -0,0 +1,9 @@
|
||||
/home/minhradz/Desktop/Rust/rustlings/exercises/clippy/target/debug/deps/libclippy3-36457a3dd0101112.rmeta: clippy3.rs Cargo.toml
|
||||
|
||||
/home/minhradz/Desktop/Rust/rustlings/exercises/clippy/target/debug/deps/clippy3-36457a3dd0101112.d: clippy3.rs Cargo.toml
|
||||
|
||||
clippy3.rs:
|
||||
Cargo.toml:
|
||||
|
||||
# env-dep:CLIPPY_ARGS=-D__CLIPPY_HACKERY__warnings__CLIPPY_HACKERY__-D__CLIPPY_HACKERY__clippy::float_cmp__CLIPPY_HACKERY__
|
||||
# env-dep:CLIPPY_CONF_DIR
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user