pub fn from_entries<K, V>(entries: &[Entry<K, V>]) -> HashMap<K, V>Expand description
Constructs a HashMap from a slice of Entry structs.
Iterates over each Entry in the provided slice and inserts them into a new HashMap.
If duplicate keys are present, the value from the last Entry with that key will be used.
§Arguments
entries- A slice ofEntrystructs to convert into aHashMap.
§Returns
HashMap<K, V>- A newHashMapcontaining all key-value pairs from theentriesslice.
§Examples
use lowdash::{Entry, from_entries};
use std::collections::HashMap;
let entries = vec![
Entry { key: "a", value: 1 },
Entry { key: "b", value: 2 },
];
let result = from_entries(&entries);
let mut expected = HashMap::new();
expected.insert("a", 1);
expected.insert("b", 2);
assert_eq!(result.len(), expected.len());
for (key, value) in &expected {
assert_eq!(result.get(key), Some(value));
}