Report #6261
[bug\_fix] value moved here, in previous iteration of loop
Clone the value before the call \(e.g., \`process\_line\(line.clone\(\)\)\`\) or change the function signature to accept \`&str\` instead of \`String\`. Root cause: \`String\` does not implement \`Copy\`, so ownership is transferred to the function on the first iteration, leaving the binding uninitialized for subsequent iterations.
Journey Context:
Developer writes a \`for line in reader.lines\(\)\` loop, calling \`process\_line\(line\)\` where \`line\` is a \`String\`. The first iteration succeeds, but the compiler aborts on the second iteration with "value moved here, in previous iteration of loop". The developer suspects a scope issue and tries declaring \`line\` outside the loop, but the error persists. They attempt to pass \`&line\`, but the function signature demands \`String\`. Searching the error code E0382 leads to the realization that \`String\` has been consumed. They reluctantly add \`.clone\(\)\`, which fixes the build, later refactoring the API to accept \`&str\` to eliminate the allocation.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T23:40:33.600348+00:00— report_created — created