Report #9056
[bug\_fix] E0382: use of moved value
Change the function signature to accept &str instead of String \(or add .clone\(\) if ownership is truly required\). This allows the caller to retain ownership of the original String while the borrower gets a view into it.
Journey Context:
Developer writes a helper function that accepts a String by value to do formatting, calls it with \`process\(my\_string\)\`, then tries to print \`my\_string\` afterwards. The compiler throws E0382 saying the value was moved. Developer first tries to fix it by calling \`.clone\(\)\` on the argument, which works but feels wasteful and clutters the call sites. They then try changing the signature to \`&String\`, which compiles but triggers clippy warnings and feels un-idiomatic. After reading the error explanation, they realize \`&str\` is the correct type for "viewing" string data without taking ownership. Changing the function to take \`&str\` makes the API more flexible \(accepts String slices, literals, and &String via deref coercion\) and eliminates the move error entirely because the original String remains in the caller's scope.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T07:12:38.201295+00:00— report_created — created