Skip to content

Instantly share code, notes, and snippets.

@heypoom
Created August 18, 2018 11:55
Show Gist options
  • Save heypoom/35874f2f97cb7df669869bfa6fee007a to your computer and use it in GitHub Desktop.
Save heypoom/35874f2f97cb7df669869bfa6fee007a to your computer and use it in GitHub Desktop.
macro_rules! mapping {
( $($key:expr => $value:expr),* ) => {
{
let mut m = HashMap::new();
$(
m.insert($key, $value);
)*
m
}
};
}
fn main() {
let me = mapping!("foo" => "bar", "bar" => "baz");
println!("{:?}", me);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment