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
1 changed files with 3 additions and 3 deletions

View File

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