How can I modify self in a closure called from a member function?
问题 I am trying to calculate legal chess moves and am having problems satisfying the borrow checker. I have a struct Chess that implements these methods (non-important code replaced by ... ): // internal iterator over (possibly not legal) moves fn get_moves<F>(&self, func: F) where F: Fn(/* ... */), { func(/* ... */); // move 1 func(/* ... */); // move 2 func(/* ... */); // etc... } fn is_legal_move(&mut self) -> bool { // notice this takes a mutable self. For performance // reasons, the move is