Function alias::one [] [src]

pub fn one<'a, T: Copy>(data: &'a mut T) -> &'a Cell<T>

Allow the mutable reference data to be mutated while aliased.

Examples

let mut x = 0;

let y = alias::one(&mut x);
let z = y;

// now we can read/write through multiple references
z.set(10);
y.set(y.get() + 2);
assert_eq!(z.get(), 12);