keys

Function keys 

Source
pub fn keys<K, V>(maps: &[&HashMap<K, V>]) -> Vec<K>
where K: Clone + Eq + Hash,
Expand description

Collects all keys from one or more maps into a single vector.

Iterates over each map and collects all keys into a single vector.

§Arguments

  • maps - One or more maps to collect keys from

§Returns

  • Vec<K> - A vector containing all keys from the input maps

§Examples

use lowdash::keys;
use std::collections::HashMap;

let mut map1 = HashMap::new();
map1.insert(1, "a");
map1.insert(2, "b");

let mut map2 = HashMap::new();
map2.insert(3, "c");
map2.insert(4, "d");

let result = keys(&[&map1, &map2]);
assert_eq!(result.len(), 4);
assert!(result.contains(&1));
assert!(result.contains(&2));
assert!(result.contains(&3));
assert!(result.contains(&4));