Closed
Description
use std::cell::RefCell;
struct S {
node: E,
}
enum E {
Foo(uint),
Bar,
}
fn main() {
let x = RefCell::new(S { node: Foo(0) });
let mut b = x.borrow_mut();
match b.node {
Foo(ref mut n) => *n += 1,
_ => (),
}
}
$ rustc -v
rustc 0.11.0 (49bc17bfdd7143909aede81652d7d624cecd8a70 2014-07-07 17:16:34 +0000)
$ rustc foo.rs
foo.rs:17:13: 17:22 error: cannot borrow immutable anonymous field as mutable
foo.rs:17 Foo(ref mut n) => *n += 1,
^~~~~~~~~
Changing to match b.deref_mut().node
fixes the error.