I am writing a container implementing the prefix tree in a generic way (key and value are generic parameters). Due to the nature of this data structure I need the key to have an iterator.
Essentially in accordance to this question the IntoIterator
trait is responsible for this possibility but not all the structures implement it. For example &str
and String
do not implement it.
What should I do in this case when IntoIterator
isn't implemented by the standard type?
An expected API is
let mut t1 = Trie::new();
t1.insert(String::from("this"), 1);
let mut t2 = Trie::new();
t2.insert(vec![1, 2, 3], 1);