I have a hm1: HashMap<K, V> where K is a tuple (k1, 2, k3) and V is a tuple of 10 elements like (v1, v2, v3, /* ... */ v10).
I have a function which acts on that HashMap, so I pass it as a parameter:
fn do_something(hm1: HashMap<(&i64, &i64, &Option<i64>), (&i64, &i64, /* ... */ &i64)>) -> () {
//Access k1, k2, k3 and v1 .. v10 and do something with it
}
I have a second HashMap hm2 where the only difference is an additional key element. hm2: HashMap<K, V> where K is a tuple (k1, k2, k3, k4) and V is again a tuple of 10 elements (v1, v2, v3, /* ... */ v10).
I would want to avoid copy pasting the same do_something() function with an adapted signature, because the logic inside is nearly the same. The difference is just that I have an additional k4 element in the tuple which I'd also access then if I have hm2.
Is there a way to generalize the HashMap<K, V> parameter so I could pass both HashMaps and act on them without duplicating my function?