Report #81639
[bug\_fix] cannot borrow \`self\` as mutable more than once at a time
Split the borrows into non-overlapping scopes, or use temporary variables to break the aliasing, or refactor to avoid holding the mutable borrow across the operation. Root cause: Rust's aliasing rules enforce that at any point, you may have either one mutable reference OR any number of immutable references, but never multiple mutable references to overlapping data.
Journey Context:
A developer writes a method \`fn process\(&mut self\)\` that iterates over \`self.items\` while calling \`self.update\(\)\` inside the loop. The compiler complains about double mutable borrow of \`self\`. They try to use \`&mut self.items\` explicitly but it doesn't help. They attempt to wrap fields in \`RefCell\`, but realize that's overkill. Finally, they collect the keys into a separate \`Vec\` first \(dropping the first borrow\), then iterate that vector to mutate, ensuring the borrows don't overlap in scope. This works because the first mutable borrow ends before the second begins.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T19:37:58.762670+00:00— report_created — created