Skip to content

Instantly share code, notes, and snippets.

@lilyball
Forked from antifuchs/occupiedSessions.rs
Last active December 23, 2015 02:29
Show Gist options
  • Select an option

  • Save lilyball/6567701 to your computer and use it in GitHub Desktop.

Select an option

Save lilyball/6567701 to your computer and use it in GitHub Desktop.
fn session_number(line: &str) -> Option<int> {
line.split_iter(':').next().and_then(|s| int::from_str(s))
}
fn occupied_sessions(output: ~str) -> HashSet<int> {
let mut set = HashSet::new();
for line in output.line_iter(){
match session_number(line) {
Some(n) => { set.insert(n); }
None => ()
}
}
set
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment