Skip to content

Instantly share code, notes, and snippets.

@scode
Created November 26, 2014 08:00
Show Gist options
  • Select an option

  • Save scode/35b4a7446d391a79021b to your computer and use it in GitHub Desktop.

Select an option

Save scode/35b4a7446d391a79021b to your computer and use it in GitHub Desktop.
for line_or_fail in io::stdin().lines() {
// XXX(scode): There is probably a much better way?
let line = line_or_fail.unwrap();
let existed = {
let existing_count = line_counts.get_mut(&line);
match existing_count {
None => { false },
Some(count) => { *count = *count + 1; true},
}
};
if !existed {
line_counts.insert(line, 1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment