macro_rules! bmap {
{} => { ... };
{ owned: $($key:expr_2021 => $value:expr_2021),+ $(,)? } => { ... };
{ $($key:expr_2021 => $value:expr_2021),+ $(,)? } => { ... };
}Available on crate feature
alloc only.Expand description
Creates an allocated BTreeMap from key-value pairs.
The owned: form calls to_owned() on each key and value.
use collections::bmap;
let map = bmap! { 1 => "one", 2 => "two" };
assert_eq!(map.len(), 2);
let owned = bmap! { owned: "key" => "value" };
assert_eq!(owned["key"], "value");