Created
December 10, 2021 10:32
-
-
Save tnibert/f06c67f15b768378280c8a3d51e47662 to your computer and use it in GitHub Desktop.
Rust hashmap example usage code
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
// hashmap example - for reference | |
let mut sample: HashMap<String, i32> = HashMap::new(); | |
sample.insert("one".to_string(), 1); | |
sample.insert("two".to_string(), 2); | |
sample.insert("three".to_string(), 3); | |
sample.insert("four".to_string(), 4); | |
for (key, value) in sample.iter() { | |
println!("{} - {}", key, value); | |
} | |
println!("four: {:?}", sample.get("four").unwrap()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment