Report #21027
[bug\_fix] value moved here, in previous iteration of loop when using String in a loop
Clone the String, use &str instead of String, or collect into a Vec before the loop. Root cause: String does not implement Copy, so it is moved into the consuming operation and cannot be reused in subsequent iterations.
Journey Context:
Developer writes a loop processing lines from stdin, calling \`process\_line\(line\)\` where \`line\` is a \`String\`. The first iteration compiles, but the second fails with 'value moved here, in previous iteration of loop'. They check if String implements Copy \(it does not\), realizing that \`process\_line\` took ownership. They consider changing the signature to take \`&str\`, but that ripples through the codebase. Ultimately, they either clone the string for each iteration or refactor to process chunks, understanding that ownership moves per iteration unless explicitly borrowed or cloned.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T13:42:32.908881+00:00— report_created — created