From d807c11fd13816c287423c856d6fc3ad9969d1d6 Mon Sep 17 00:00:00 2001 From: Andrew Coleman Date: Thu, 8 Dec 2022 12:30:57 -0500 Subject: [PATCH] cargo clippy --fix --- 2022/src/days/day2.rs | 6 +++--- 2022/src/days/day4.rs | 6 +++--- 2022/src/days/day5.rs | 6 +++--- 2022/src/days/day6.rs | 6 +++--- 2022/src/days/day7.rs | 6 +++--- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/2022/src/days/day2.rs b/2022/src/days/day2.rs index 1697a9e..f19f655 100644 --- a/2022/src/days/day2.rs +++ b/2022/src/days/day2.rs @@ -79,9 +79,9 @@ pub fn run() -> Result<()> { let part_two_score = match part_two_goal { EndStates::Lose => match opponent { - Pieces::Rock => 3 + 0, - Pieces::Paper => 1 + 0, - Pieces::Scissors => 2 + 0, + Pieces::Rock => 3, + Pieces::Paper => 1, + Pieces::Scissors => 2, }, EndStates::Draw => match opponent { Pieces::Rock => 1 + 3, diff --git a/2022/src/days/day4.rs b/2022/src/days/day4.rs index 9dd8e1e..59fe33f 100644 --- a/2022/src/days/day4.rs +++ b/2022/src/days/day4.rs @@ -13,9 +13,9 @@ pub fn run() -> Result<()> { let mut part_two_pairs = 0; for line in lines { - let v: Vec<&str> = line.split(",").collect(); - let left: Vec = v[0].split("-").map(|t| t.parse::().unwrap()).collect(); - let right: Vec = v[1].split("-").map(|t| t.parse::().unwrap()).collect(); + let v: Vec<&str> = line.split(',').collect(); + let left: Vec = v[0].split('-').map(|t| t.parse::().unwrap()).collect(); + let right: Vec = v[1].split('-').map(|t| t.parse::().unwrap()).collect(); let left_outside = left[0] <= right[0] && left[1] >= right[1]; let left_inside = left[0] >= right[0] && left[1] <= right[1]; diff --git a/2022/src/days/day5.rs b/2022/src/days/day5.rs index 6b295e0..03d452d 100644 --- a/2022/src/days/day5.rs +++ b/2022/src/days/day5.rs @@ -14,10 +14,10 @@ pub fn run() -> Result<()> { let mut containers: Vec<&str> = Vec::with_capacity(20); for line in file_contents.lines() { - if line.contains("[") { + if line.contains('[') { containers.push(line); } else { - for stacknums in line.split(" ") { + for stacknums in line.split(' ') { if let Ok(num) = stacknums.parse::() { numstacks = num; stacks.push(Vec::with_capacity(100)) @@ -43,7 +43,7 @@ pub fn run() -> Result<()> { continue; } - let mut tokens = line.split(" "); + let mut tokens = line.split(' '); let count = tokens.nth(1).expect("missing count").parse::()?; let from = tokens.nth(1).expect("missing from").parse::()?; let to = tokens.nth(1).expect("missing to").parse::()?; diff --git a/2022/src/days/day6.rs b/2022/src/days/day6.rs index a1fb871..6c1162a 100644 --- a/2022/src/days/day6.rs +++ b/2022/src/days/day6.rs @@ -20,7 +20,7 @@ fn unique_run_position<'a>(line: &'a str, count: usize) -> usize { } } - return char_counter; + char_counter } pub fn run() -> Result<()> { @@ -35,8 +35,8 @@ pub fn run() -> Result<()> { for line in lines { line_counter += 1; - let index = unique_run_position(&line, 4); - let index2 = unique_run_position(&line, 14); + let index = unique_run_position(line, 4); + let index2 = unique_run_position(line, 14); println!("line {}\t{}\t{}", line_counter, index, index2); } diff --git a/2022/src/days/day7.rs b/2022/src/days/day7.rs index dc73fc7..4414b5e 100644 --- a/2022/src/days/day7.rs +++ b/2022/src/days/day7.rs @@ -139,10 +139,10 @@ pub fn run() -> Result<()> { let new_filename = format!("/{}", current_path.join("/")); current_path.pop(); - if let None = current.files.iter().find(|x| x.name == new_filename) { + if !current.files.iter().any(|x| x.name == new_filename) { current.files.push(File { name: new_filename, - size: size, + size, }); } } else if line.starts_with("dir") { @@ -152,7 +152,7 @@ pub fn run() -> Result<()> { let new_dirname = format!("/{}", current_path.join("/")); current_path.pop(); - if let None = current.directories.iter().find(|x| x.name == new_dirname) { + if !current.directories.iter().any(|x| x.name == new_dirname) { let dir = Dir { name: new_dirname, ..Default::default()