I'm having a hard time with the borrow checker.
for item in self.xxx.iter() {
self.modify_self_but_not_xxx(item);
}
The above code worked before I refactored some code into modify_self_but_not_xxx()
:
error: cannot borrow `*self` as mutable because `self.xxx` is also borrowed as immutable
How can I call a mutating method while holding a reference to self
(e.g. from within a for
-loop)?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…