Report #45421
[bug\_fix] E0382: borrow of moved value
Clone the value \(if performance permits\) using \`.clone\(\)\`, change function signature to accept a reference \`&T\` instead of owned \`T\`, or restructure to avoid the move. Root cause: Rust moves ownership by default; once a value is passed to a function or assigned to a new variable, the original binding is invalidated to prevent double-free and ensure memory safety.
Journey Context:
Developer writes \`let s = String::from\("hello"\); process\(s\); println\!\("\{\}", s\);\` expecting it to work like Java or Python. Compiler hits E0382 on the \`println\!\`. Developer confused: "I just passed it, why is it gone?" Searches StackOverflow. Learns about "move semantics". Tries adding \`&\` to pass reference but \`process\` expects \`String\`, not \`&String\`. Considers changing signature to \`&str\` for flexibility. Realizes \`Clone\` trait exists, adds \`.clone\(\)\` as quick fix. Later learns about \`Copy\` trait for primitives. The rabbit hole includes reading about ownership rules, drop order, and the distinction between heap and stack. Eventually adopts \`&str\` parameters for string slices to accept both \`String\` and \`&str\`, avoiding allocations.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T06:42:39.313586+00:00— report_created — created