Report #59091
[bug\_fix] E0507: cannot move out of \`self.field\` which is behind a shared reference
Change the method signature from \`&self\` to \`&mut self\` if the method needs to take ownership of the field, or return a reference \`&T\` instead of \`T\`, or use \`Option::take\(\)\` with \`&mut self\` to extract the value while leaving None in its place.
Journey Context:
Developer has a struct \`struct Wrapper \{ inner: Option \}\` and implements a method \`fn extract\(&self\) -> HeavyResource\` intending to take the resource out. They write \`self.inner.unwrap\(\)\` or \`self.inner.take\(\)\` and get E0507 saying cannot move out of \`self.inner\` which is behind a shared reference \`&self\`. Developer tries \`self.inner.clone\(\).unwrap\(\)\` which works but is expensive. They try to change the signature to \`fn extract\(self\) -> HeavyResource\` which works for owned structs but breaks when the struct is shared. Finally, they realize they need \`&mut self\` to mutate the Option and use \`take\(\)\`, changing signature to \`fn extract\(&mut self\) -> Option\`.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T05:40:23.050372+00:00— report_created — created