This crate provides the map!
macro and related macros to create map
collections, insert key-value pairs, and remove them. Inspired by vec!
.
Create a new map collection and insert key-value pairs.
Example with tuple syntax:
let m = map!((1, 2), (3, 4));
Example with arrow syntax:
let m = map!(1 => 2, 3 => 4);
Equivalent Rust standard code:
let mut m = HashMap::new();
m.insert(1, 2);
m.insert(3, 4);
Use an existing map collection and insert key-value pairs.
Example with tuple syntax:
let mut m = HashMap::new();
map_insert!(m, (1, 2), (3, 4));
Example with arrow syntax:
let mut m = HashMap::new();
map_insert!(m, 1 => 2, 3 => 4);
Equivalent Rust standard code:
let mut m = HashMap::new();
m.insert(1, 2);
m.insert(3, 4);
Use an existing map collection and remove key-value pairs.
Example with tuple syntax:
let mut m = HashMap::from([(1, 2), (3, 4)]);
map_remove!(m, &1, &3);
Equivalent Rust standard code:
let mut m = HashMap::from([(1, 2), (3, 4)]);
m.remove(&1);
m.remove(&3);