Report #103445
[bug\_fix] error\[E0382\]: use of moved value: \`s\`
Clone the value when you need two owners: \`let t = s.clone\(\); println\!\("\{\}", s\);\`. Or, better, restructure so the second use borrows instead of taking ownership: \`let t = &s;\`. For small \`Copy\` types like \`i32\` this error does not occur.
Journey Context:
You assign \`let t = s;\` for a \`String\` and then try to print \`s\`. The compiler stops you with E0382. At first you expect both variables to hold the string, as in many other languages, but Rust moves ownership by default for types that do not implement \`Copy\`. The \`String\` heap allocation now belongs to \`t\`; \`s\` is considered uninitialized. You think about implementing \`Copy\` for your wrapper, but you cannot implement \`Copy\` for types that own heap memory because a bitwise copy would create two owners of the same allocation. Cloning creates a new heap allocation with an independent copy of the data, so both \`s\` and \`t\` are valid. Borrowing avoids the copy entirely by letting \`t\` read \`s\` without taking ownership. The fix works because it restores Rust's single-owner invariant.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-11T04:24:24.955790+00:00— report_created — created