Lifetimes for method returning iterator of structs with same lifetime
问题 Assume the following contrived example: struct Board { squares: Vec<i32>, } struct Point<'a> { board: &'a Board, x: i32, y: i32, } impl<'a> Point<'a> { pub fn neighbors(&self) -> impl Iterator<Item = Point<'a>> { [(0, -1), (-1, 0), (1, 0), (1, 0)] .iter().map(|(dx, dy)| Point { board: self.board, x: self.x + dx, y: self.y + dy, }) } } This doesn't compile because from what I understand the lifetime of the points created in the lambda isn't correct: error[E0495]: cannot infer an appropriate