day02: Use iterator instead of temporary Vec
This commit is contained in:
parent
60f4e24250
commit
1001e9dd0f
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue