I want to define a generic struct that has a member that can provide an iterator that i can call repeatedly to iterate over its collection (non moving).
pub struct<Children> {
children: Children
}
Basically I want my struct's children
be repeatedly iteratable, so I can have a method for my struct:
pub fn doit(&self) {
for c in &self.children {
//do something with c
}
}
So that children could be a Vec<> or some linked list that can be iterated over, or something else..
I'm assuming I need to make a reference to my generic parameter implement IntoIterator
?
this is the closest i've come so for:Rust Playground
Any pointers on how I can make this work?