pub struct RcPool<T: Clone> { /* private fields */ }Expand description
A pool of reference-counted slot values, indexed by integer ID.
Implementations§
Source§impl<T: Clone> RcPool<T>
impl<T: Clone> RcPool<T>
Sourcepub fn insert(&mut self, value: T) -> RcPoolIdx
pub fn insert(&mut self, value: T) -> RcPoolIdx
Insert a value, returning an index with refcount 1.
Sourcepub fn dec_ref(&mut self, idx: RcPoolIdx) -> bool
pub fn dec_ref(&mut self, idx: RcPoolIdx) -> bool
Decrement the refcount. Returns true if the object was freed.
Sourcepub fn get_mut(&mut self, idx: RcPoolIdx) -> Option<&mut T>
pub fn get_mut(&mut self, idx: RcPoolIdx) -> Option<&mut T>
Get a mutable reference (unique access).
Sourcepub fn cow(&mut self, idx: RcPoolIdx) -> Option<RcPoolIdx>
pub fn cow(&mut self, idx: RcPoolIdx) -> Option<RcPoolIdx>
Clone-on-write: if refcount > 1, clone the value into a new slot.
Sourcepub fn live_count(&self) -> usize
pub fn live_count(&self) -> usize
Number of live slots.
Sourcepub fn alloc_count(&self) -> u64
pub fn alloc_count(&self) -> u64
Total allocation count.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for RcPool<T>
impl<T> RefUnwindSafe for RcPool<T>where
T: RefUnwindSafe,
impl<T> Send for RcPool<T>where
T: Send,
impl<T> Sync for RcPool<T>where
T: Sync,
impl<T> Unpin for RcPool<T>where
T: Unpin,
impl<T> UnsafeUnpin for RcPool<T>
impl<T> UnwindSafe for RcPool<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more