day02: Use iterator instead of temporary Vec

2022
MasterofJOKers 1 year ago
parent 60f4e24250
commit 1001e9dd0f

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

Loading…
Cancel
Save