Created
September 27, 2022 10:09
-
-
Save okabe-yuya/6061197a294901d7b9b527a83fdca668 to your computer and use it in GitHub Desktop.
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 field_name = String::from("Favorite color"); | |
let field_value = String::from("Blue"); | |
let mut map = HashMap::new(); | |
map.insert(&field_name, field_value); | |
let score = map.get(&field_name); | |
match score { | |
None => println!("None"), | |
Some(x) => println!("Get value: {}", x), | |
} | |
for (key, value) in &map { | |
println!("{}: {}", key, value); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment