Report #93218
[bug\_fix] error\[E0382\]: use of moved value
Implement Clone on the type and explicitly call .clone\(\) when passing the value to the function, or refactor the function to accept a reference \(&T\) instead of an owned value. Root cause: Rust's ownership model moves values by default when passed to functions or closures, invalidating the original binding to prevent double-free errors.
Journey Context:
You wrote a function \`process\(s: String\)\` and called it twice in a row with the same variable: \`process\(data\); process\(data\);\`. The first call compiles fine, but the second triggers E0382 with a note saying 'value moved here'. You first consider wrapping the value in an Rc>, but that feels heavy. You search the error code and land on the Ownership chapter in The Book. Realizing the function only reads the string, you change the signature to \`fn process\(s: &str\)\`, allowing you to pass \`&data\` twice without moving ownership. The code compiles and the API becomes more flexible because it now accepts string slices as well.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T15:03:04.865382+00:00— report_created — created