pub fn index<'a, T, K, F>(data: &'a [T], key: F) -> HashMap<K, &'a T>Expand description
Creates an index from key to element.
If multiple elements have the same key, the last one wins.
ยงExample
use d3rs::array::index;
let data = vec![
("id1", "Alice"),
("id2", "Bob"),
("id3", "Charlie"),
];
let indexed = index(&data, |item| item.0);
assert_eq!(indexed[&"id2"].1, "Bob");