diff --git a/2022/day01/src/input.txt b/2022/day01/input.txt similarity index 100% rename from 2022/day01/src/input.txt rename to 2022/day01/input.txt diff --git a/2022/day01/src/main.rs b/2022/day01/src/main.rs index 7c5e7fe..066a4be 100644 --- a/2022/day01/src/main.rs +++ b/2022/day01/src/main.rs @@ -7,12 +7,12 @@ fn read_lines(filename: &str) -> io::Result<io::Lines<io::BufReader<File>>> { Ok(io::BufReader::new(file).lines()) } -fn main() { +fn main() -> Result<(), io::Error> { let mut max = 0; let mut current = 0; - for line in read_lines("input.txt").unwrap() { - let text = line.unwrap(); + for line in read_lines("input.txt")? { + let text = line?; current = match text.parse::<i32>() { Ok(value) => current + value, Err(_) => { @@ -23,4 +23,5 @@ fn main() { } println!("{}", max); + Ok(()) }