Function alias::slice
[−]
[src]
pub fn slice<'a, T: Copy>(data: &'a mut [T]) -> &'a [Cell<T>]
Allow the contents of the mutable slice data
to be mutated while
aliased.
Examples
let mut x = [0, 0, 0, 0]; let y = alias::slice(&mut x); let z = y; // now we can read/write through multiple references for i in 0..4 { z[i].set(10); y[i].set(y[i].get() + i); } assert_eq!(z[0].get(), 10); assert_eq!(z[1].get(), 11); assert_eq!(z[2].get(), 12); assert_eq!(z[3].get(), 13);