logo
macro_rules! sgmap {
    ( $capacity:expr $(, $key:expr => $value:expr)* $(,)? ) => { ... };
}
Expand description

Create an SgMap from a list of key-value pairs. Capacity precedes the list.

Examples

use scapegoat::{SgMap, sgmap};

let mut map = sgmap! {
    4, // Const capacity
    "a" => 0x61,
    "b" => 0x62,
    "c" => 0x63,
};

assert_eq!(map["a"], 0x61);
assert_eq!(map["b"], 0x62);
assert_eq!(map["c"], 0x63);

assert_eq!(map.get("d"), None);
assert_eq!(map.capacity(), 4);
assert_eq!(map.len(), 3);

map.insert("d", 0x64);
assert_eq!(map["d"], 0x64);