Report #10252
[bug\_fix] E0382 use of moved value
Clone the value before moving it \(\`.clone\(\)\`\), change the function signature to accept a reference \`&T\` instead of owned \`T\`, or restructure to avoid multiple ownership needs. Root cause: Rust's ownership system prevents use-after-move to avoid double-free memory errors.
Journey Context:
Developer writes a helper function \`process\(v: Vec\)\` that takes ownership of a vector, processes it, and drops it. They then try to call \`process\(vec\)\` twice or use \`vec\` again afterward. The compiler emits E0382: 'use of moved value: \`vec\`'. The developer initially tries to \`\#\[derive\(Copy\)\]\` on Vec \(impossible\) or resorts to \`unsafe\` code. After consulting the book, they realize the function should take \`&Vec\` or \`&\[i32\]\` if it only needs to read, or they must explicitly \`.clone\(\)\` if they truly need two independent owners. The fix works because it satisfies the borrow checker's requirement that every value has exactly one owner at a time.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T10:13:21.094065+00:00— report_created — created