Report #100988
[bug\_fix] cannot move out of \`self\` which is behind a shared reference
Change the method to take \`self\` \(owned\) if ownership transfer is intended, clone the field, or use \`std::mem::replace\`/\`Option::take\` to extract the value while leaving a valid placeholder in its place.
Journey Context:
You have a method on \`&self\` that tries to take ownership of a field, perhaps returning an \`Option\` field by value. The compiler rejects it because \`&self\` is a shared borrow and moving a field out would leave a partial struct. You consider making the method take \`&mut self\`, but the caller only has \`&self\`. You look at the real intent: either the caller should own the value, in which case you change the signature to \`self\`; or the field is an \`Option\` and you can \`std::mem::replace\` it with \`None\`, leaving the struct valid. If the value is cheap to clone, \`self.field.clone\(\)\` is the simplest path. You pick the option that preserves the borrow semantics and the compiler is happy.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-06T04:47:41.305559+00:00— report_created — created