[][src]Type Definition swim_mem::lease::MutBuf

type MutBuf<'a, T, M = ()> = Mut<'a, Buf<T, M>>;

Mutably dereferenceable strong owner of a resizeable array of values stored in a Hold-allocated, atomically reference counted memory block.

Examples

Create an empty MutBuf that will allocate space in the global hold:

let buf = MutBuf::<u8>::empty();

Clone a slice into a newly allocated MutBuf:

let buf = MutBuf::<u8>::from_clone(&[2, 3]);

Push values onto the end of a MutBuf, growing its capacity as needed:

let mut buf = MutBuf::<u8>::from_clone(&[1, 2]);
buf.push(3);

Pop values off of the end of a MutBuf:

let mut buf = MutBuf::<u8>::from_clone(&[1, 2]);
let two = buf.pop();

Access elements by index:

let mut buf = MutBuf::<u8>::from_clone(&[1, 2, 3]);
let three = buf[2];
buf[1] *= 2;