pub fn assign<K, V>(maps: &[HashMap<K, V>]) -> HashMap<K, V>Expand description
Merges multiple maps into a single map. If the same key exists in multiple maps, the value from the last map is used.
§Arguments
maps- A variadic number of maps to merge.
§Returns
HashMap<K, V>- The merged map.
§Examples
use lowdash::assign;
use std::collections::HashMap;
let mut map1 = HashMap::new();
map1.insert("a", 1);
let mut map2 = HashMap::new();
map2.insert("b", 2);
let merged = assign(&[map1, map2]);
assert_eq!(merged.get("a"), Some(&1));
assert_eq!(merged.get("b"), Some(&2));