Created
November 26, 2014 08:00
-
-
Save scode/35b4a7446d391a79021b 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
| 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