#hash-map #macro

hashmap_macro

hashmap macro for creating hashmap from provided key/value pairs

1 unstable release

0.1.0 Sep 30, 2022

#15 in #hashmap

MIT license

4KB

HashMap Macro

Creates a HashMap from provided key/value pairs.

Usage

use std::collections::HashMap;
use hashmap_macro::hashmap;

let m: HashMap<&str, u32> = hashmap![];
let m: HashMap<&str, u32> = hashmap!("a" => 1);
let m: HashMap<&str, u32> = hashmap! {
    "a" => 1,
    "b" => 2,
};

Inspired by Jon Gjengset's Crust of Rust: Declarative Macros

No runtime deps