day02: Use iterator instead of temporary Vec

This commit is contained in:
MasterofJOKers 2022-12-15 17:46:34 +01:00
parent 60f4e24250
commit 1001e9dd0f
1 changed files with 3 additions and 3 deletions

View File

@ -53,9 +53,9 @@ fn main() -> Result<(), Box<dyn error::Error>> {
let mut sum: u32 = 0;
for line in reader.lines() {
let line = line?;
let split_result: Vec<&str> = line.split_whitespace().collect();
let other = Values::get_from_str(&split_result[0]);
let my = Values::get_from_str(&split_result[1]);
let mut split_result = line.split_whitespace().map(|o| Values::get_from_str(o));
let other = split_result.next().unwrap();
let my = split_result.next().unwrap();
sum += my.get_u32();
if other == my {
sum += 3;