I’m trying to develop a simple directory walker. Short version: I have a directory node stack, each node contains a VecDeque of directory elements to process. I want to keep looping while there are directory nodes to process, and in that loop keep looping while there are directory entries to process.
This will not build because pop_front() needs a mutable variable, but it can’t borrow one because there’s already a reference to the struct. I understand what the problem is, and I understand that I need to restructure the code – but whatever solutions I come up with keep having the same problem. I fear that my brain is stuck in a way of thinking which isn’t compatible with the borrow/mutability checker. So I’m looking for some inspiration.