pub fn map_entries<K1, V1, K2, V2, F>(
map: &HashMap<K1, V1>,
iteratee: F,
) -> BTreeMap<K2, V2>Expand description
Transforms the entries of a map using a provided function.
§Arguments
map- The input map whose entries are to be transformed.iteratee- A function that takes a reference to a key and its value, returning a new key and value.
§Returns
BTreeMap<K2, V2>- A new map with transformed entries.
§Examples
use lowdash::map_entries;
use std::collections::HashMap;
let mut map = HashMap::new();
map.insert("a", 1);
map.insert("b", 2);
let transformed = map_entries(&map, |k, v| (k.to_uppercase(), v * 10));
assert_eq!(transformed.get("A"), Some(&10));
assert_eq!(transformed.get("B"), Some(&20));