has_key

Function has_key 

Source
pub fn has_key<K, V>(map: &HashMap<K, V>, key: &K) -> bool
where K: Eq + Hash,
Expand description

Checks if a map contains a specific key.

§Arguments

  • map - The map to check for the key
  • key - The key to check for in the map

§Returns

  • bool - true if the key is present in the map, false otherwise

§Examples

use lowdash::has_key;
use std::collections::HashMap;

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

assert!(has_key(&map, &"a"));
assert!(!has_key(&map, &"c"));