How do I move out of a struct field that is an Option?
I want to collect changes to a struct and apply them all at once. The basic outline looks like this: enum SomeEnum { Foo, Bar, } struct SomeStruct { attrib: SomeEnum, next_attrib: Option<SomeEnum>, } impl SomeStruct { pub fn apply_changes(&mut self) { if let Some(se) = self.next_attrib { self.attrib = se; } self.next_attrib = None; } } which yields the following compiler error: error[E0507]: cannot move out of borrowed content --> src/lib.rs:13:27 | 13 | if let Some(se) = self.next_attrib { | -- ^^^^ cannot move out of borrowed content | | | hint: to prevent move, use `ref se` or `ref mut se`