use std::io; use std::io::prelude::*; use std::fs::File; fn read_lines(filename: &str) -> io::Result>> { let file = File::open(filename)?; Ok(io::BufReader::new(file).lines()) } fn main() -> Result<(), io::Error> { let mut max = 0; let mut current = 0; for line in read_lines("input.txt")? { let text = line?; current = match text.parse::() { Ok(value) => current + value, Err(_) => { if current > max { max = current; } 0 }, }; } println!("{}", max); Ok(()) }