use std::fs::File; use std::io::{self, BufRead}; use std::path::Path; fn main() { let file_path = String::from("../aoc_04a/input"); let mut result = 0; println!("In file {}", file_path); if let Ok(lines) = read_lines(file_path) { // Consumes the iterator, returns an (Optional) String for line in lines { if let Ok(ip) = line { let split = ip.split(","); let mut vec = Vec::::new(); for s in split { let split = s.split("-"); for s in split { vec.push(s.parse().unwrap()); } } if !(vec[1] < vec[2] || vec[0] > vec[3]) { result += 1; } } } } println!("{}", result); } fn read_lines

(filename: P) -> io::Result>> where P: AsRef, { let file = File::open(filename)?; Ok(io::BufReader::new(file).lines()) }