Rust: error[E0382]: borrow of moved value: `x`
A value was moved (ownership transferred) and then used again.
Seen on:
Rust
Meaning
Types like String and Vec move when passed by value or assigned. After a move, the original variable can’t be used. Borrow (&x), clone when you really need two owners, or restructure ownership.
Common causes
- Passing a String/Vec by value to a function and using it after
- Moving into a closure (move ||) or thread
- Using a value after a for loop consumed it (for x in vec)
⚡ Quick fix
- Pass a reference (&value) instead
- .clone() if you need an independent copy
- Iterate by reference (for x in &vec)
Detailed fix by platform
Rust
- rust
fn print_len(s: &String) { println!("{}", s.len()); } let name = String::from("Ada"); print_len(&name); println!("{name}"); // still usable
How to diagnose
- Move — Line with "value moved here"
- Type — Implements Copy?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
🧠 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.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 7 Oct 2026