pub fn map_keys<K, V, R, F>(map: &HashMap<K, V>, iteratee: F) -> BTreeMap<R, V>Expand description
Transforms the keys of a map using a provided function.
§Arguments
map- The input map whose keys are to be transformed.iteratee- A function that takes a reference to a value and its key, returning a new key.
§Returns
BTreeMap<R, V>- A new map with transformed keys.
§Examples
use lowdash::map_keys;
use std::collections::HashMap;
let mut map = HashMap::new();
map.insert("a", 1);
map.insert("b", 2);
let transformed = map_keys(&map, |&v, &k| format!("key_{}", k));
assert_eq!(transformed.get("key_a"), Some(&1));
assert_eq!(transformed.get("key_b"), Some(&2));