Created
June 1, 2017 04:56
-
-
Save DmitrySoshnikov/621241bf461f37a8c8cceef11d0a18d3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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! map( | |
{ $($key:expr => $value:expr),+ } => { | |
{ | |
let mut m = ::std::collections::HashMap::new(); | |
$( | |
m.insert($key, $value); | |
)+ | |
m | |
} | |
}; | |
); | |
fn main() { | |
let names = map!{ 1 => "one", 2 => "two" }; | |
println!("{} -> {:?}", 1, names.get(&1)); | |
println!("{} -> {:?}", 10, names.get(&10)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment