Rust: error[E0499]: cannot borrow `v` as mutable more than once at a time
Two mutable references to the same value were alive at once, which Rust forbids.
error[E0499]: cannot borrow `v` as mutable more than once at a timecannot borrow `*self` as mutable more than once at a timeE0499 second mutable borrow occurs herefirst mutable borrow occurs herecannot borrow as mutable more than once at a time Meaning
Only one &mut may exist at a time. Shorten the first borrow's scope (let it end before the second), split the data (split_at_mut), use indices instead of holding references, or use interior mutability (RefCell) when truly needed. NLL ends borrows at last use, so reorder code.
Common causes
- Two
&muttaken before the first is last used - Mutable borrow stored in a struct/closure
- Loop calling
&mut selfmethods while holding a reference - Iterating a vec while mutating it
- Calling a method that borrows
selfmutably while another field borrow exists
⚡ Quick fix
- End the first borrow before the second (restructure/reorder)
- Use
split_at_mut/indices or clone small data - Use
RefCell/Mutexfor shared mutation
Detailed fix by platform
Rust
let (a, b) = v.split_at_mut(mid); a[0] += b[0];
How to diagnose
- Borrows — Where do both live?
- Scope — Can the first end earlier?
- Alternative — split/indices?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- Blocking waiting for file lock on package cache / build directory Cargo: Blocking waiting for file lock on package cache / on build directory
- cargo: failed to get from registry (spurious network error) Cargo: warning: spurious network error (2 tries remaining): [35] SSL connect error / error: failed to download from `https://index.crates.io/...`
- E0382 Rust: error[E0382]: borrow of moved value: `x`
Most viewed in Rust
- E0308 Rust: error[E0308]: mismatched types — expected `X`, found `Y`
- feature edition2024 is required / Cargo.lock version too new Cargo: error: failed to parse manifest — feature `edition2024` is required / lock file version 4 requires `-Znext-lockfile-bump`
- E0015: cannot call non-const function in constants Rust: error[E0015]: cannot call non-const function `String::from` in constants
Other ways to find it
Where this error sits
Origin: Application & API. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 5 Nov 2026