Skip to content

Instantly share code, notes, and snippets.

@okabe-yuya
Created September 27, 2022 10:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save okabe-yuya/6061197a294901d7b9b527a83fdca668 to your computer and use it in GitHub Desktop.
Save okabe-yuya/6061197a294901d7b9b527a83fdca668 to your computer and use it in GitHub Desktop.
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