Remove redundant into_iter and collect

This commit is contained in:
Vladan Popovic 2020-01-14 15:29:40 +01:00
parent 74cd67ddfc
commit 39235ce0cf

View file

@ -13,11 +13,11 @@ fn total_fuel(mass: u64) -> u64 {
pub fn main() -> io::Result<()> {
let f = BufReader::new(File::open("day1-input.txt")?);
let masses: Vec<u64> = f
let total: u64 = f
.lines()
.map(|line| line.unwrap().parse().unwrap())
.collect();
let total: u64 = masses.into_iter().map(total_fuel).sum();
.map(total_fuel)
.sum();
println!("Fuel needed for bringing Santa home is: {}", total);
Ok(())