Rust and Cargo 1 · Code patterns
Use a HashMap
Insert values and read them back.
use std::collections::HashMap;
let mut scores = HashMap::new();
scores.insert("ada", 10);
let score = scores.get("ada").copied().unwrap_or(0);
Official Rust and Cargo 1 documentation