Report #65835
[bug\_fix] cannot borrow \`vec\` as mutable more than once at a time \[E0499\]
Restructure the code so the first mutable borrow goes out of scope before the second borrow begins, or use \`drop\(borrow\_var\)\` explicitly to end the borrow early. If simultaneous mutation is architecturally required, refactor to use interior mutability \(\`RefCell\`, \`Mutex\`\) or split the data structure.
Journey Context:
Developer is iterating over a \`Vec\` while conditionally pushing new elements, or holding a reference to an element while later calling \`vec.push\(\)\`. The compiler flags the second mutable borrow. Developer tries to wrap code in extra braces to create scope, but the borrow still lives due to non-lexical lifetime analysis. They realize they need to either collect indices to modify later, use \`retain\(\)\` for in-place mutation, or explicitly \`drop\(\)\` the first borrow before the second.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T16:59:17.493305+00:00— report_created — created