From 410295c8002ab818d8ea2886c9d0c34f475d6405 Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Mon, 4 Jul 2022 02:01:22 +0100 Subject: [PATCH] Improve map! macro to allow extending the map with other map --- src/mac/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mac/mod.rs b/src/mac/mod.rs index 8b157d3d..877f3b03 100644 --- a/src/mac/mod.rs +++ b/src/mac/mod.rs @@ -1,6 +1,7 @@ macro_rules! map { - ($($k:expr => $v:expr),* $(,)?) => {{ + ($($k:expr => $v:expr),* $(,)? $( => $x:expr )?) => {{ let mut m = ::std::collections::BTreeMap::new(); + $(m.extend($x.iter().map(|(k, v)| (k.clone(), v.clone())));)? $(m.insert($k, $v);)+ m }};