Overflow evaluating the requirement when returning a recursive iterator using impl trait
问题 I'm trying to iterate depth-first over a tree structure in Rust. I thought I had a really nice concise solution for this, but I can't get it to compile. Conceptually it's pretty simple: iterate over the children, get each child's depth first iterator, flatten them, and chain the current node's metadata iterator to it. #[derive(Debug, Eq, PartialEq)] struct Node { metadata: Vec<i64>, children: Vec<Box<Node>>, } impl Node { fn depth_first_metadata_iter(&self) -> impl Iterator<Item = &i64> + '_