Added comment to explain second example

pull/45/head
Andre Bogus 8 years ago
parent d827cec092
commit 964dd9932b

@ -51,6 +51,8 @@ enum MultiVariateEnum {
fn swizzle(e: &mut MultiVariateEnum) {
use self::MultiVariateEnum::*;
*e = match *e {
// Ownership rules do not allow taking `name` by value, but we cannot
// take the value out of a mutable reference, unless we replace it:
A { ref mut name } => B { name: mem::replace(name, String::new()) },
B { ref mut name } => A { name: mem::replace(name, String::new()) },
C => D,

Loading…
Cancel
Save