Report #95252
[bug\_fix] error\[E0499\]: cannot borrow \`vec\` as mutable more than once at a time
Restructure the code to release the first mutable borrow before taking the second, or use \`split\_mut\(\)\` to get disjoint mutable references, or employ interior mutability \(RefCell\) if runtime borrow checking is acceptable.
Journey Context:
You're writing a function that needs to push to a Vec while also holding a reference to an element. You get \`&mut vec\` then try to get \`&mut vec\[idx\]\` inside the same scope. The compiler complains about multiple mutable borrows overlapping. You try to use separate blocks but realize the first borrow lasts too long due to the scope. You look into \`split\_mut\` or refactoring to collect indices first then modify, or using \`RefCell\` if single-threaded runtime borrowing is acceptable. The root cause is Rust's aliasing XOR mutation rule.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T18:27:30.060135+00:00— report_created — created