pub struct CWeakArray<T, TAllocator: Allocator> { /* private fields */ }Expand description
A weak reference to the underlying CArcArray.
This object cannot inspect the underlying value (unless T is Copy).
But it does track weak references, and each weak reference can build
a strong reference, assuming any other strong reference is alive.
Implementations§
Source§impl<T, TAllocator: Allocator> CWeakArray<T, TAllocator>
impl<T, TAllocator: Allocator> CWeakArray<T, TAllocator>
Sourcepub fn strong_count(&self) -> u32
pub fn strong_count(&self) -> u32
Returns the number of strong references to the CWeakArray.
Sourcepub fn weak_count(&self) -> u32
pub fn weak_count(&self) -> u32
Returns the number of weak references to the CWeakArray.
Sourcepub fn upgrade(&self) -> Result<CArcArray<T, TAllocator>, WeakUpgradeError>
pub fn upgrade(&self) -> Result<CArcArray<T, TAllocator>, WeakUpgradeError>
Sourcepub fn data(&self) -> &[T]where
T: Copy,
pub fn data(&self) -> &[T]where
T: Copy,
Returns a reference to the underlying slice.
This function is only available if T implements Copy.
That is because being Copy means it is not Drop. And
so we don’t need strong references to keep the data alive.
Sourcepub fn abandon(self) -> bool
pub fn abandon(self) -> bool
Abandons current weak reference.
If the internal weak counter is positive it returns false.
Otherwise it deallocates the underlying memory and returns true.
In particular only single (the last) CWeakArray returns true
by calling this.