Report #21635
[bug\_fix] cannot borrow \`self\` as mutable more than once at a time \(E0499\)
Restructure to avoid simultaneous borrows: use temporary variables, split the struct into sub-fields using pattern matching \(\`let Self \{ field1, field2 \} = self\`\), or iterate by index. The root cause is Rust's aliasing rules forbid two mutable references \(\`&mut T\`\) to the same data simultaneously. This often happens when iterating over a collection in \`self\` while calling other \`&mut self\` methods inside the loop.
Journey Context:
You have a struct with a \`Vec\` and a counter. You write a method \`process\` that iterates over \`&self.items\` and calls \`self.increment\(\)\` \(which takes \`&mut self\`\) inside the loop. The compiler stops with E0499. You try to refactor \`increment\` to take \`&mut u32\`, but then you need to mutate the vec inside the same loop. You realize you can't hold a reference to the vec while mutating the struct. You search 'rust cannot borrow self as mutable more than once'. You find suggestions to split the borrows. You destructure: \`let Self \{ vec, counter \} = self;\` then loop over \`vec\` and mutate \`counter\`. This satisfies the borrow checker because the borrows are disjoint. You compile successfully.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T14:43:47.201257+00:00— report_created — created2026-06-17T14:57:58.330689+00:00— confirmed_via_duplicate_submission — confirmed