cargo clippy --fix
parent
e636d4266b
commit
d807c11fd1
|
@ -79,9 +79,9 @@ pub fn run() -> Result<()> {
|
||||||
|
|
||||||
let part_two_score = match part_two_goal {
|
let part_two_score = match part_two_goal {
|
||||||
EndStates::Lose => match opponent {
|
EndStates::Lose => match opponent {
|
||||||
Pieces::Rock => 3 + 0,
|
Pieces::Rock => 3,
|
||||||
Pieces::Paper => 1 + 0,
|
Pieces::Paper => 1,
|
||||||
Pieces::Scissors => 2 + 0,
|
Pieces::Scissors => 2,
|
||||||
},
|
},
|
||||||
EndStates::Draw => match opponent {
|
EndStates::Draw => match opponent {
|
||||||
Pieces::Rock => 1 + 3,
|
Pieces::Rock => 1 + 3,
|
||||||
|
|
|
@ -13,9 +13,9 @@ pub fn run() -> Result<()> {
|
||||||
let mut part_two_pairs = 0;
|
let mut part_two_pairs = 0;
|
||||||
|
|
||||||
for line in lines {
|
for line in lines {
|
||||||
let v: Vec<&str> = line.split(",").collect();
|
let v: Vec<&str> = line.split(',').collect();
|
||||||
let left: Vec<u32> = v[0].split("-").map(|t| t.parse::<u32>().unwrap()).collect();
|
let left: Vec<u32> = v[0].split('-').map(|t| t.parse::<u32>().unwrap()).collect();
|
||||||
let right: Vec<u32> = v[1].split("-").map(|t| t.parse::<u32>().unwrap()).collect();
|
let right: Vec<u32> = v[1].split('-').map(|t| t.parse::<u32>().unwrap()).collect();
|
||||||
|
|
||||||
let left_outside = left[0] <= right[0] && left[1] >= right[1];
|
let left_outside = left[0] <= right[0] && left[1] >= right[1];
|
||||||
let left_inside = left[0] >= right[0] && left[1] <= right[1];
|
let left_inside = left[0] >= right[0] && left[1] <= right[1];
|
||||||
|
|
|
@ -14,10 +14,10 @@ pub fn run() -> Result<()> {
|
||||||
|
|
||||||
let mut containers: Vec<&str> = Vec::with_capacity(20);
|
let mut containers: Vec<&str> = Vec::with_capacity(20);
|
||||||
for line in file_contents.lines() {
|
for line in file_contents.lines() {
|
||||||
if line.contains("[") {
|
if line.contains('[') {
|
||||||
containers.push(line);
|
containers.push(line);
|
||||||
} else {
|
} else {
|
||||||
for stacknums in line.split(" ") {
|
for stacknums in line.split(' ') {
|
||||||
if let Ok(num) = stacknums.parse::<usize>() {
|
if let Ok(num) = stacknums.parse::<usize>() {
|
||||||
numstacks = num;
|
numstacks = num;
|
||||||
stacks.push(Vec::with_capacity(100))
|
stacks.push(Vec::with_capacity(100))
|
||||||
|
@ -43,7 +43,7 @@ pub fn run() -> Result<()> {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut tokens = line.split(" ");
|
let mut tokens = line.split(' ');
|
||||||
let count = tokens.nth(1).expect("missing count").parse::<usize>()?;
|
let count = tokens.nth(1).expect("missing count").parse::<usize>()?;
|
||||||
let from = tokens.nth(1).expect("missing from").parse::<usize>()?;
|
let from = tokens.nth(1).expect("missing from").parse::<usize>()?;
|
||||||
let to = tokens.nth(1).expect("missing to").parse::<usize>()?;
|
let to = tokens.nth(1).expect("missing to").parse::<usize>()?;
|
||||||
|
|
|
@ -20,7 +20,7 @@ fn unique_run_position<'a>(line: &'a str, count: usize) -> usize {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return char_counter;
|
char_counter
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run() -> Result<()> {
|
pub fn run() -> Result<()> {
|
||||||
|
@ -35,8 +35,8 @@ pub fn run() -> Result<()> {
|
||||||
|
|
||||||
for line in lines {
|
for line in lines {
|
||||||
line_counter += 1;
|
line_counter += 1;
|
||||||
let index = unique_run_position(&line, 4);
|
let index = unique_run_position(line, 4);
|
||||||
let index2 = unique_run_position(&line, 14);
|
let index2 = unique_run_position(line, 14);
|
||||||
println!("line {}\t{}\t{}", line_counter, index, index2);
|
println!("line {}\t{}\t{}", line_counter, index, index2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -139,10 +139,10 @@ pub fn run() -> Result<()> {
|
||||||
let new_filename = format!("/{}", current_path.join("/"));
|
let new_filename = format!("/{}", current_path.join("/"));
|
||||||
current_path.pop();
|
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 {
|
current.files.push(File {
|
||||||
name: new_filename,
|
name: new_filename,
|
||||||
size: size,
|
size,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else if line.starts_with("dir") {
|
} else if line.starts_with("dir") {
|
||||||
|
@ -152,7 +152,7 @@ pub fn run() -> Result<()> {
|
||||||
let new_dirname = format!("/{}", current_path.join("/"));
|
let new_dirname = format!("/{}", current_path.join("/"));
|
||||||
current_path.pop();
|
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 {
|
let dir = Dir {
|
||||||
name: new_dirname,
|
name: new_dirname,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
|
Loading…
Reference in New Issue