メモ
全然挙動がわからないのため https://play.rust-lang.org/ で動作確認しながら進めてる。
ハッシュマップからstringで文字列を取り出す。
use std::collections::HashMap;
fn main() {
let mut scores = HashMap::new();
scores.insert(String::from("Blue"), 10);
scores.insert(String::from("Yellow"), 50);
let team_name = String::from("Blue");
let score = scores.get(&team_name).unwrap();
println!("{}", score);
}
// 結果
// Standard Error
// Compiling playground v0.0.1 (/playground)
// Finished dev [unoptimized + debuginfo] target(s) in 0.76s
// Running `target/debug/playground`
// Standard Output
// 10