diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 843b14f..20141c4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,15 +21,14 @@ jobs: - name: Cargo Test run: | - cargo test + cargo test --release - name: Cargo Clippy run: | - cargo clippy -- -W clippy::pedantic -W clippy::nursery -W clippy::unwrap_used + cargo clippy --release -- -W clippy::pedantic -W clippy::nursery -W clippy::unwrap_used - name: Cargo Build Binary run: | - cd rust cargo build --release chmod +x target/release/${{ github.event.repository.name }} diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 2dfcd54..006b5ac 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -13,15 +13,33 @@ }, "label": "rust: cargo build", }, + { + "type": "cargo", + "command": "clippy", + "problemMatcher": [ + "$rustc" + ], + "args": [ + "--fix", + "--allow-dirty", + "--", + "-W", + "clippy::pedantic", + "-W", + "clippy::nursery", + "-W", + "clippy::unwrap_used", + ], + "group": "build", + "label": "rust: cargo clippy fix", + }, { "type": "cargo", "command": "build", "problemMatcher": [ "$rustc" ], - "group": { - "kind": "build", - }, + "group": "build", "args": [ "--release" ], diff --git a/src/phone_gen.rs b/src/phone_gen.rs index 4095f81..fb53ece 100644 --- a/src/phone_gen.rs +++ b/src/phone_gen.rs @@ -47,8 +47,8 @@ impl Options { let combinations = Some(10 - prefix.to_string().len()); Self { country_code: country_code.into(), - prefix: format!("{country_code}{prefix}").into(), - combinations: combinations.into(), + prefix: format!("{country_code}{prefix}"), + combinations, file: file.into(), } } diff --git a/src/russian_roulette.rs b/src/russian_roulette.rs index a83c6ef..fb9779d 100644 --- a/src/russian_roulette.rs +++ b/src/russian_roulette.rs @@ -38,7 +38,7 @@ impl Gun { _ => println!("Barrel with size {} opened", &barrel_size), } let mut barrel = vec![false; barrel_size as usize]; - let mut hammer_pos: usize = 0; + let mut hammer_pos: u8 = 0; match bullets { 0 => panic!("0 Bullets!"), _ => { @@ -47,19 +47,16 @@ impl Gun { } else { println!("Barrel loading with {} bullets", &bullets); while bullets > 0 { - hammer_pos = (c_rand_u8() % barrel_size) as usize; - if barrel[hammer_pos] == false { - barrel[hammer_pos] = true; + hammer_pos = c_rand_u8() % barrel_size; + if !barrel[hammer_pos as usize] { + barrel[hammer_pos as usize] = true; bullets -= 1; } } } } } - Self { - barrel: barrel, - hammer_pos: hammer_pos as u8, - } + Self { barrel, hammer_pos } } // Trigger gun an fire round if loaded in barrel @@ -68,9 +65,9 @@ impl Gun { let real_pos = self.hammer_pos as usize % self.barrel.len(); if self.barrel[real_pos] { self.barrel[real_pos] = false; - println!("BAAANNG!!") + println!("BAAANNG!!"); } else { - println!("*Click*, {} empty", real_pos) + println!("*Click*, {real_pos} empty"); } } }