[−][src]Type Definition swim_mem::lease::HardBuf
type HardBuf<'a, T, M = ()> = Hard<'a, Buf<T, M>>;
Undereferenceable strong owner of a resizeable array of values stored in a
Hold
-allocated, atomically reference counted memory block.
Examples
Create an empty HardBuf
that will allocate space in the global hold:
let buf = HardBuf::<u8>::empty();
Clone a slice into a newly allocated HardBuf
:
let buf = HardBuf::<u8>::from_clone(&[2, 3]);
Obtain a mutably dereferenceable MutBuf
lease from a HardBuf
, copying
its contents into a new, uniquely referenced buffer if and only if the old
buffer is aliased, and push values onto the end of the dealiased buffer,
growing its capacity as needed:
let mut buf = HardBuf::<u8>::from_clone(&[1, 2]); buf.to_unique().push(3);
Obtain an immutably dereferenceable RefBuf
lease from a HardBuf
, and
access its elements by index:
let buf = HardBuf::<u8>::from_clone(&[1, 2, 3]); let three = buf.to_ref()[2];