[][src]Macro col_macros::btree_map

macro_rules! btree_map {
    (for $map:expr, ins $( $k:expr => $v:expr ),*) => { ... };
    (for $map:tt, ins $( $k:tt => $v:tt ,)*) => { ... };
    ( $( $k:expr => $v:expr ),*) => { ... };
    ( $( $k:tt => $v:tt ,)*) => { ... };
}

Construct or update a map of type BTMap<K, V> which can be and is an alias to BTreeMap<K, V> in the types module.

All types of maps are accepted but if a map has capacity and their respective methods, hash_map! is preferred.

Examples

use col_macros::btree_map;
use col_macros::types::BTMap;

let mut hash = btree_map!["key1" => 1, "key2" => 2];
let mut hash2 = {
    let mut temp = BTMap::new();
    temp.insert("key1", 1);
    temp.insert("key2", 2);
    temp
};

assert_eq!(hash["key1"], 1);
assert_eq!(hash["key2"], 2);

assert_eq!(hash2["key1"], 1);
assert_eq!(hash2["key2"], 2);

btree_map![for &mut hash, ins "key3" => 3, "key4" => 4];

assert_eq!(hash["key3"], 3);
assert_eq!(hash["key4"], 4);