use std::collections::HashSet; use std::error::Error as StdError; use std::fs::File; use std::io::{self, BufRead, BufReader}; use std::path::Path; use std::result::Result as StdResult; use crate::graph; pub type Location = String; pub type Distance = u64; pub type Graph = graph::Graph; pub type Node = graph::Node; pub type NodeSet = HashSet; pub type Error = Box; pub type Result = StdResult; pub fn parse_file

(path: P) -> io::Result where P: AsRef, { let file = BufReader::new(File::open(path)?); let mut directions = Graph::default(); for line in file.lines() { let line = line?; let words = line.split(' ').collect::>(); let location = ( words[0].to_string(), words[2].to_string(), words[4].parse::().unwrap(), ); directions.add_edge(&location); } Ok(directions) }