Summation Over Lines in a File (Advent of Code 2018 Day 1)
That's how you use Iterator::sum:

use std::fs::File;
use std::io::{self, prelude::*, BufReader};

fn main() -&gt; io::Result&lt;()&gt; {
    let file = File::open("day01.txt")?;
    let reader = BufReader::new(file);
    let sum: i32 = reader
        .lines()
        .map(|line| line.unwrap().parse::&lt;i32&gt;().unwrap())
        .sum();

    println!("{}", sum);

    Ok(())
}


You must first say to what type the line must be parsed: parse::&lt;i32&gt;() and then, you must give the sum a type because the output of the Add trait is not the same as self and other.