pub fn omit_by<K, V, F>(map: &HashMap<K, V>, predicate: F) -> HashMap<K, V>Expand description
Filters a map by omitting key-value pairs that satisfy a predicate.
Iterates over each key-value pair in the input map and excludes it from the result map
if the predicate returns true for that pair.
§Arguments
map- The input map to filter.predicate- A function that takes a key and value, and returnstrueif the pair should be omitted.
§Returns
HashMap<K, V>- A new map containing only the key-value pairs that do not satisfy the predicate.
§Examples
use lowdash::omit_by;
use std::collections::HashMap;
let mut map = HashMap::new();
map.insert("a", 1);
map.insert("b", 2);
map.insert("c", 3);
// Omit entries where the value is greater than 1
let result = omit_by(&map, |_, v| *v > 1);
assert_eq!(result.len(), 1);
assert!(result.contains_key("a"));
assert!(!result.contains_key("b"));
assert!(!result.contains_key("c"));