You can't.
@
is immutable.- Managed boxes are being steadily destroyed, so you shouldn't use them.
@mut
has been removed from the language.
There is, however, a way of getting around this: RefCell
. If you wrap an object in it then you can modify it even though it appears to be immutable. This is sometimes useful, but where possible you should avoid it. Here's an example of using it (with Gc
; you should probably tend to use Rc
at present instead, because Gc
is not properly implemented):
let steve = box(GC) RefCell::new(Monster { legs: 2 });
steve.borrow().borrow_mut().get().legs = 8;
assert_eq!(steve.borrow().borrow().get().legs, 8);
It's not pretty; smart pointer traits may well improve the situation. But where possible, avoid such things. Immutable data is good, task-local data is good.