Created
May 30, 2019 05:52
-
-
Save hikilaka/83b77dde19ed1e92bd7ea5377582e113 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
macro_rules! hashmap { | |
($($key:expr => $value:expr), +) => ({ | |
let mut map = std::collections::HashMap::new(); | |
$( | |
map.insert($key, $value); | |
)+ | |
map | |
}); | |
} | |
fn main() { | |
let map = hashmap!{ 1 => "one", 2 => "two", 3 => "three" }; | |
println!("{:?}", map); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment