Created
December 13, 2017 04:40
-
-
Save anonymous/f03a4aa626d0109bd1b0f3d6372d18f1 to your computer and use it in GitHub Desktop.
Rust code shared from the playground
This file contains 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
use std::collections::HashMap; | |
fn main() { | |
let mut map = HashMap::new(); | |
let words = vec!["quux", "bar", "floorgle", "bar"]; | |
for word in words.iter() { | |
let word = *word; | |
let mut cond = false; | |
{ | |
let x = map.entry(word).or_insert(0); | |
cond = *x < 3; | |
} | |
if cond { | |
let y = map.entry(words[word.len() % words.len()]).or_insert(0); | |
*y += 1; | |
println!("Hello, world!"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment