But I get the error: cannot move out of a shared reference, if I remove the *, I obviously get mismatched types because it's cloning a reference. If I do (*list).clone() I get the error:
the method `clone` exists for struct `Vec<Node<T, U>>`, but its trait bounds were not satisfied
the following trait bounds were not satisfied:
`Node<T, U>: Clone`
which is required by `Vec<Node<T, U>>: Clone`
So, I'm not quite sure where to go from here? Suggestions?
You are almost there with (*list).clone(), but for a Vec to be Clone all its elements also need to be Clone. The issue here isn't strictly with the generics, but with the fact that it doesn't know that a Node is Clone. I would probably go for implementing Clone all in one go, as in this playground. I've added PhantomData, since otherwise the T and U parameters are unused and I'm not sure quite what you want to do with them. Depending on what you want to do with T and U, they may also need a Clone bound on them. Once you have Clone for Node<T,U>, a clone_children() should work with (*list).clone() (playground with clone_children()).