pub struct Gc<T>where
T: Trace + 'static,{ /* private fields */ }Expand description
A strong, reference-counted handle to a heap value.
Gc<T> is a pointer-sized handle: cloning is cheap, Deref gives &T,
and the value is released as soon as the last handle is gone (cycles need
Heap::collect).
Implementations§
Source§impl<T> Gc<T>where
T: Trace + 'static,
impl<T> Gc<T>where
T: Trace + 'static,
Sourcepub fn strong_count(&self) -> usize
pub fn strong_count(&self) -> usize
Number of strong handles (including internal edges).
Sourcepub fn upgrades_to(&self, other: &WeakGc<T>) -> bool
pub fn upgrades_to(&self, other: &WeakGc<T>) -> bool
Whether this handle points at the box other refers to, expired or not.
A WeakMap stores weak handles but compares against live keys, so the comparison
has to span both handle types without upgrading (which would resurrect the key).
Trait Implementations§
Source§impl<T> Trace for Gc<T>where
T: Trace + 'static,
impl<T> Trace for Gc<T>where
T: Trace + 'static,
Source§fn external_bytes(&self) -> usize
fn external_bytes(&self) -> usize
What the pointee owns, which is counted against the pointee’s own box.
Forwarded so that gc.external_bytes() is not a silent zero, but a container must
never add this to its own total: it would count the child’s payload twice, once here
and once when the child’s box is registered.