I’m trying to get a trait or two in place to allow me to write generic code over a few different datastructures for the same logical pile of data (a two-level trie). It is surprisingly hard.

The goal is to write something that is morally the same as a HashMap<K, Vec<(T, Vec<(V,i32)>)>> , and in particular should allow you to get iterators over (&V,i32) pairs from a K and a T , and also an iterator over (&T, ThatIterator<V>) . However, you should be able to define the types of the iterators, because maybe you didn’t use a Vec because … reasons.