Run ❯
Get your
own
website
❯
Run Code
Ctrl+Alt+R
Change Orientation
Ctrl+Alt+O
Change Theme
Ctrl+Alt+D
Change Language
Go to Spaces
Ctrl+Alt+P
use std::collections::HashMap; fn main() { let mut capital_cities = HashMap::new(); // Add keys and values (Country, City) capital_cities.insert("England", "London"); capital_cities.insert("Germany", "Berlin"); capital_cities.insert("Norway", "Oslo"); // Loop through the HashMap for (country, city) in &capital_cities { println!("The capital of {} is {}.", country, city); } }
The capital of England is London.
The capital of Germany is Berlin.
The capital of Norway is Oslo.