use std::fs::File; use std::io::{self, BufRead}; use std::path::Path; use regex::Regex; fn main() { if let Ok(lines) = read_lines("./input") { for line in lines { if let Ok(text) = line { Game g = parse_game(text); } else { println!("Error on line \"{:?}\"", line); } } } } struct Bag { red: u32, green: u32, blue: u32, } struct Set { red: u32, green: u32, blue: u32, } struct Game { ID: u32, Vec, } fn parse_game(text: &String) -> Result { let re = Regex::new(r"^Game ([0-9]+)(?:(?:(?::|;) )((?:[0-9]+ (?:red|blue|green)(?:, )?)+))+$").unwrap(); // TODO: Extract all captures. The second capture group only returns the last of the match. } fn read_lines

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