I have the following code:
pub struct Tree<T> {
root: Box<Node<T>>,
elements: HashSet<T>,
}
impl<T> Tree<T> {
pub fn new<I>(source: I) -> Option<Tree<T>>
where
I: std::iter::Iterator,
<I as Iterator>::Item: Hash,
<I as Iterator>::Item: Eq,
{
...
}
How do I propagate <I as Iterator>::Item
type to T
? In other words, how can I write code like this:
let tree = Tree::new("test".chars());