E0499: cannot borrow as mutable more than once at a time Rust Origin: Application & API OSI layer 7 · Application Last updated 5 Nov 2026

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.

Exact message you may see 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
Seen on: Rust

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 &mut taken before the first is last used
  • Mutable borrow stored in a struct/closure
  • Loop calling &mut self methods while holding a reference
  • Iterating a vec while mutating it
  • Calling a method that borrows self mutably while another field borrow exists

⚡ Quick fix

  1. End the first borrow before the second (restructure/reorder)
  2. Use split_at_mut/indices or clone small data
  3. Use RefCell/Mutex for shared mutation

Detailed fix by platform

Rust

  1. let (a, b) = v.split_at_mut(mid); a[0] += b[0];

How to diagnose

  1. Borrows — Where do both live?
  2. Scope — Can the first end earlier?
  3. 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:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

Blocking waiting for file lock on package cache / build directory — Cargo: Blocking waiting for file lock on package cache / on build directory (Rust)Blocking waiting for …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/...` (Rust)cargo: failed to get …E0382 — Rust: error[E0382]: borrow of moved value: `x` (Rust)E0382E0502 — Rust: error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable (Rust)E0502E0505: cannot move out of value because it is borrowed — Rust: error[E0505]: cannot move out of `s` because it is borrowed (Rust)E0505: cannot move ou…E0596: cannot borrow as mutable, as it is not declared as mutable — Rust: error[E0596]: cannot borrow `v` as mutable, as it is not declared as mutable (Rust)E0596: cannot borrow …E0597: borrowed value does not live long enough — Rust: error[E0597]: `x` does not live long enough — borrowed value does not live long enough (Rust)E0597: borrowed value…panic: already borrowed: BorrowMutError — Rust: thread 'main' panicked at src/main.rs:8:9: already borrowed: BorrowMutError / already mutably borrowed: BorrowError (Rust)panic: already borrow…E0499: ca…

Explore the map of this error Full error map →

🧠 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.