Report #60991
[bug\_fix] use of moved value: E0382
Change the function signature to accept a reference \(\`&String\` or \`&str\`\) instead of taking ownership by value, or clone the value before the move if both copies are legitimately required. This satisfies the borrow checker by ensuring the original owner retains valid access to the data.
Journey Context:
The developer is writing a parser that consumes a \`String\` to build an AST. They pass the string into a helper function \`parse\_header\(input: String\) -> Header\`, and then try to print the original string for debugging. The compiler emits E0382: "use of moved value". The developer initially panics, thinking they need to deep copy everything. They try \`.clone\(\)\` on the String before passing it, which compiles but feels inefficient. They check the Rust Book Chapter 4.1 and realize that Rust defaults to move semantics for non-Copy types. They understand that the helper function doesn't actually need ownership—it only needs to read the string. They refactor \`parse\_header\` to take \`&str\` instead, allowing the caller to retain ownership. This eliminates the move, avoids the clone, and satisfies the borrow checker.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T08:51:42.495835+00:00— report_created — created