Function nexsys_core::split_hm

source ·
pub fn split_hm<K, V>(hm: HashMap<K, V>) -> (Vec<K>, Vec<V>)
Expand description

Returns a tuple of Vecs that contain the keys and values of the original HashMap. The index of the key will be the same as its corresponding value’s index.

Example

use std::collections::HashMap;
use nexsys_core::split_hm;
 
let my_map = HashMap::from([
    ("a", 1),
    ("b", 2),
    ("c", 3)
]);
 
let vecs = split_hm(my_map.clone());
  
assert_eq!(my_map[vecs.0[0]], vecs.1[0])