Improve map! macro to allow extending the map with other map
This commit is contained in:
parent
983a7b3f5c
commit
410295c800
1 changed files with 2 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
||||||
macro_rules! map {
|
macro_rules! map {
|
||||||
($($k:expr => $v:expr),* $(,)?) => {{
|
($($k:expr => $v:expr),* $(,)? $( => $x:expr )?) => {{
|
||||||
let mut m = ::std::collections::BTreeMap::new();
|
let mut m = ::std::collections::BTreeMap::new();
|
||||||
|
$(m.extend($x.iter().map(|(k, v)| (k.clone(), v.clone())));)?
|
||||||
$(m.insert($k, $v);)+
|
$(m.insert($k, $v);)+
|
||||||
m
|
m
|
||||||
}};
|
}};
|
||||||
|
|
Loading…
Reference in a new issue