From 249d43ea0ec6eed871bc7cb30aa9ee0ff0ed553f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tomas=20Wenstr=C3=B6m?= Date: Sun, 17 Jan 2021 18:39:34 +0100 Subject: [PATCH] Added a hashmap macro --- src/common.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/common.rs b/src/common.rs index d2121b0..01c0238 100644 --- a/src/common.rs +++ b/src/common.rs @@ -193,6 +193,17 @@ impl From<(T, T)> for Rect { } } +#[macro_export] +macro_rules! hashmap { + ($($k:expr => $v:expr),*) => { + { + let mut map = std::collections::HashMap::new(); + $(map.insert($k, $v);)* + map + } + } +} + #[cfg(test)] mod tests { use super::*; -- 2.11.0