use std::fs::File; use std::io::{self, BufRead}; use std::path::Path; use std::collections::HashMap; fn main() { let file_path = String::from("../aoc_06a/input"); let mut index = 14; 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 mut len = 0; while len != 14 { let mut hashmap = HashMap::new(); let slice = &ip[(index - 14)..index]; for c in slice.chars() { hashmap.insert(c, 0); } len = hashmap.len(); index += 1; } } } } println!("{}", index - 1); } fn read_lines

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