From dcf077f81520d43678cc84206d53ffcdebe227e1 Mon Sep 17 00:00:00 2001 From: Beppe Date: Tue, 6 Dec 2022 00:54:50 +0100 Subject: [PATCH] removed some unnecessary mutables --- day_4/src/main.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/day_4/src/main.rs b/day_4/src/main.rs index 05e9811..860c90c 100644 --- a/day_4/src/main.rs +++ b/day_4/src/main.rs @@ -14,7 +14,7 @@ struct Assignment { fn parse_assignment(unparsed_assignment: &str) -> Assignment { let parts:Vec<&str> = unparsed_assignment.split("-").collect(); - return Assignment {start: parts[0].clone().parse::().unwrap(), end: parts[1].clone().parse::().unwrap()}; //this won't work but internet is down :/ + return Assignment {start: parts[0].clone().parse::().unwrap(), end: parts[1].clone().parse::().unwrap()}; //ugliest code known to man } fn check_contain(check_team: &Team) -> bool { @@ -37,9 +37,9 @@ fn main() { let assignments = line.split(",").collect::>(); //NOTE the ::<... part seems to be generic rust //Rust can also get this typing from the var it's going to put the output in // let assignments: Vec<&str> = line.split().collect(); - let mut first_assignment = parse_assignment(assignments[0]); - let mut second_assignment = parse_assignment(assignments[1]); - let mut temp_team = Team {first: first_assignment, second: second_assignment}; + let first_assignment = parse_assignment(assignments[0]); + let second_assignment = parse_assignment(assignments[1]); + let temp_team = Team {first: first_assignment, second: second_assignment}; if check_contain(&temp_team) { contain_counter += 1; }