Wrapper Types in Rust
Cell types
interior mutability
can be manipulated even if the type cannot be obtained in a mutable form.
cannot be used in a threadsafe manner, this makes them cheaper to use.
Cell<T>
zero-cost interior mutability, but only for Copy types.
the contained value is on the stack.
RefCell<T>
isn't restricted to Copy types, but it has a runtime cost.
these are can be done by using borrow() and borrow_mut().
code:refcell.rs
{
println!("{:?}", *x.borrow())
}
{
let my_ref = x.borrow_mut();
my_ref.push(1);
}