Report #30218
[bug\_fix] value moved here, in previous iteration of loop / use of moved value
Clone the value before moving with \`.clone\(\)\`, change the function signature to accept a reference \`&T\` instead of owned \`T\`, or restructure to avoid reusing the value. Root cause: Rust's ownership system enforces that each value has exactly one owner; when a value is passed to a function or assigned without the Copy trait, ownership transfers and the original binding becomes invalid to prevent double-free and data races.
Journey Context:
Developer writes a loop processing user input Strings, calling \`process\_string\(item\)\` where the function takes \`String\` \(owned\). Immediately after, they try to push \`item\` into a \`history\` Vec, triggering "use of moved value". Confused, they try \`&item\` but the signature rejects references. They search the error and learn about the Copy trait, but String is not Copy. They consider wrapping in \`Rc>\` but that seems complex. Finally, they realize the function only needs to read the data, so changing the signature to \`fn process\_string\(s: &str\)\` and calling \`process\_string\(&item\)\` allows them to retain ownership and push to history afterward.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T05:06:29.633357+00:00— report_created — created