Module for wrapping freezable data structures in managed boxes. Normally freezable data structures require an unaliased reference, such as T
or ~T
, so that the compiler can track when they are being mutated. The managed<T>
type converts these static checks into dynamic checks: your program will fail if you attempt to perform mutation when the data structure should be immutable.
Mut
type Mut<T> = Data<T>
Mode
ReadOnly
Mutable
Immutable
Data
struct Data <T>{
priv mut value: T,
priv mut mode: Mode,
}
Data<T>
borrow_mut
fn borrow_mut<R>(op: &fn(t: &mut T) -> R) -> R
borrow_const
fn borrow_const<R>(op: &fn(t: &const T) -> R) -> R
borrow_imm
fn borrow_imm<R>(op: &fn(t: &T) -> R) -> R
unwrap
fn unwrap() -> T
Mut
fn Mut<T>(t: T) -> Mut<T>
unwrap
fn unwrap<T>(m: Mut<T>) -> T