Editor's note: This code is from a version of Rust prior to 1.0 and is not syntactically or semantically valid Rust 1.0 code.
So, scoping out shared box pointers as a learning exercise. Purely academic exercise.
#[feature(managed_boxes)];
struct Monster {
legs: int
}
fn main() {
let mut steve = @Monster{ legs: 2 };
steve.legs = 8;
}
I'm a little surprised to be getting this compiler error:
shared_box.rs:10:5: 10:15 error: cannot assign to immutable field
shared_box.rs:10 steve.legs = 8;
What gives?
The error goes away if I switch to an Owned Box pointer. Is this some kind of restriction on managed pointer access?