From 21d0ccd59ad73f24fd91ee5015d32d80c89838df Mon Sep 17 00:00:00 2001 From: Andrew Coleman Date: Mon, 3 Dec 2018 13:33:10 -0500 Subject: [PATCH] use .sum() on an iterator --- 2018/day1/src/main.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/2018/day1/src/main.rs b/2018/day1/src/main.rs index da76224..ac89b7d 100644 --- a/2018/day1/src/main.rs +++ b/2018/day1/src/main.rs @@ -3,10 +3,7 @@ use std::io::{BufRead, BufReader}; use std::iter::Iterator; fn print_final_frequency(ints: &Vec) { - let mut frequency = 0; - for drift in ints { - frequency = frequency + drift; - } + let frequency: i32 = ints.iter().sum(); println!("frequency is {}", frequency) }