Created
October 3, 2017 16:53
-
-
Save teburd/981ef0533135715e333a0c803fac976b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn sync(&mut self) -> EventResult<()> { | |
let mut agencies: Vec<&str> = Vec::new(); | |
let mut routes: HashMap<&str, Vec<&str>> = HashMap::new(); | |
let mut stops: HashMap<&str, Vec<&str>> = HashMap::new(); | |
{ | |
for transit in self.transit.iter() { | |
match transit.as_tuple() { | |
(agency, "", "") => agencies.push(agency), | |
(agency, route, "") => { | |
let mut agency_routes = routes.entry(agency).or_insert(Vec::new()); | |
agency_routes.push(route); | |
}, | |
(agency, "", stop) => { | |
let mut agency_stops = stops.entry(agency).or_insert(Vec::new()); | |
agency_stops.push(stop); | |
} | |
_ => unreachable!(), | |
} | |
} | |
} | |
self.transit.clear(); | |
Ok(()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment