Skip to content

Instantly share code, notes, and snippets.

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

  • Save scode/7aa897c4c174b008303a to your computer and use it in GitHub Desktop.

Select an option

Save scode/7aa897c4c174b008303a to your computer and use it in GitHub Desktop.
for line_or_fail in io::stdin().lines() {
let entry = line_counts.entry(line_or_fail.unwrap());
match entry {
Occupied(mut entry) => { *entry.get_mut() = *entry.get_mut() + 1; },
Vacant(entry) => { entry.set(1); },
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment