Report #59683
[bug\_fix] value used here after move \[E0382\]
Clone the value before moving it, or construct the value inside the loop so each iteration creates a new owned instance. Alternatively, if the type implements Copy \(like i32\), it will implicitly copy instead of move.
Journey Context:
You're writing a batch processor that collects database records. You write 'let template = Record::default\(\);' outside a 'for \_ in 0..10' loop, intending to push it into a Vec ten times. On the first 'vec.push\(template\);', the compiler stops with 'value used here after move'. You stare at it, thinking 'I'm just putting it in the vector, why is it gone?' You realize that in Rust, pushing to a Vec moves the value into the Vec's heap allocation, consuming 'template'. After the first iteration, 'template' is uninitialized. The second iteration tries to move it again, which is illegal. You facepalm, remembering that Rust has move semantics by default for non-Copy types. You fix it by either cloning inside the loop 'vec.push\(template.clone\(\)\)', or moving the construction inside the loop so each iteration creates its own owned Record. This is the classic 'move in loop' gotcha that every Rust developer hits when coming from garbage-collected languages.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T06:40:10.006706+00:00— report_created — created