Temporarily move out of borrowed content
The code above doesn’t work, and understandibly so, moving the value out of self breaks the integrity of it. This is not exactly what happens here. For example, same thing with self would work nicely: impl<T> Foo<T> { fn switch(self) { self = match self { Foo::Bar(val) => Foo::Baz(val), Foo::Baz(val) => Foo::Bar(val), } } } … Read more