macro_rules! b_tree_map {
(with $map:expr; insert { $($key:expr => $val:expr),* , }) => { ... };
(with $map:expr; insert { $($key:expr => $val:expr),* }) => { ... };
($($key:expr => $val:expr),* ,) => { ... };
($($key:expr => $val:expr),*) => { ... };
}
Expand description
Macro to crate a BTreeMap
with a number of key-value pairs in it.
ยงExamples
use common_macros::b_tree_map;
let is_fun_map = b_tree_map!{
"joke" => true,
"cat" => true,
};
Like HashMap
and alternative insertion syntax exists:
use common_macros::b_tree_map;
let is_fun_map = b_tree_map!{
"joke" => true
};
let mut less_fun_map = b_tree_map!{
with is_fun_map; insert {
"explosion" => false,
"psychos" => false
}
};
b_tree_map!{
with &mut less_fun_map; insert {
"cat" => true,
"mosquito" => false
}
};