1
0
Fork 0

use .sum() on an iterator

main
Andrew Coleman 2018-12-03 13:33:10 -05:00
parent dd3d4a7929
commit 21d0ccd59a
1 changed files with 1 additions and 4 deletions

View File

@ -3,10 +3,7 @@ use std::io::{BufRead, BufReader};
use std::iter::Iterator; use std::iter::Iterator;
fn print_final_frequency(ints: &Vec<i32>) { fn print_final_frequency(ints: &Vec<i32>) {
let mut frequency = 0; let frequency: i32 = ints.iter().sum();
for drift in ints {
frequency = frequency + drift;
}
println!("frequency is {}", frequency) println!("frequency is {}", frequency)
} }