Report #11367
[bug\_fix] cannot move out of \`self.field\` which is behind a shared reference \(or use of moved value in \`Fn\` closure\)
If the field is \`Option\`, use \`self.field.take\(\)\` to move the value out while leaving \`None\` in its place. Otherwise, change the method to take \`self\` \(consuming ownership\) or \`&mut self\` if you only need to mutate, or clone the value if copying is acceptable.
Journey Context:
Developer is implementing a state machine or a builder pattern. They have a method on \`&self\` that attempts to move a value out of a field to return it, or they have a closure \(e.g., in \`map\` or \`and\_then\`\) that captures a variable from the environment by value \(move\) but the closure itself is required to be \`Fn\` \(called multiple times\). In the first case, the compiler errors because moving a field out of a borrowed struct would leave the struct in an invalid partially-moved state. The developer discovers \`Option::take\(\)\` as a pattern for moving values out of borrowed structs safely. In the closure case, they realize they cannot move a value into a closure that might be called twice; they either clone the value outside the closure or change the API to accept \`FnOnce\`.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T13:12:22.301455+00:00— report_created — created