Created
January 8, 2024 12:22
-
-
Save mizar/90b5fa8678b30026b046ba5d46d7294c 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 greet_map(id: usize, name: String) -> HashMap<usize, String> { | |
let mut map = HashMap::new(); | |
let message = format!("Hello, {}!", name); | |
map.insert(id, message); | |
map | |
} | |
fn main() { | |
let map = greet_map(0, String::from("world")); | |
for (&i, s) in map.iter() { | |
println!("{} {}", i, s); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment