What does error E0382 borrow of moved value mean in Rust?
Why Rust moves values
Rust tracks ownership so each value has one owner at a time. When you pass a non-copy value, such as a String or a Vec, into a function by value, ownership moves into that function. The original variable can no longer be used, and the compiler reports E0382.
This rule prevents double frees and data races at compile time. The error is not a bug in your logic so much as a sign that the ownership design needs adjusting for how the data is used.
- Read the note in the error that shows where the move happened
- Check whether the function really needs ownership
- Look at whether the type implements Copy
Common fixes
If the function only needs to read the value, change the parameter to a reference, such as &String or &Vec. The caller keeps ownership and can keep using the value afterward.
If you truly need two independent copies, call clone on the value before the move. Cloning costs memory and time, so use it on purpose rather than as a default fix for every move error.
If the value is a large structure, cloning can be expensive, so consider passing a reference or restructuring the function. Read the compiler's suggestion carefully, since it often names the exact fix.
Common mistakes
- Cloning everywhere just to silence the compiler.
- Ignoring the move note and guessing at the fix.

Related questions
- What does expected declaration or statement at end of input mean in C?
- How do I fix a missing return statement error in Java?
- What does cannot find package mean in Go?
- Why do I get a duplicate class error in Java?
- What does no matching function for call to mean in C++?
- How do I fix an unresolved external symbol error in C++?