Weak
Retains a shared control block while permitting the payload to expire.
Module std.memory
import std.memory;Public declaration contracts and authored examples. A page can document several related symbols. Implementation bodies are excluded.
Weak
pub final class Weak<T, A = DefaultAllocator>
where T: Movable where A: Allocator, Defaultable, MovableRetains a shared control block while permitting the payload to expire.
Copying retains only weak control ownership and never copies T. Upgrade atomically acquires a new strong handle or returns none after expiry; it never resurrects a destroyed payload. Separate published handles support concurrent retention/release, while access to the same mutable handle requires external synchronization. No payload borrow is available directly from Weak. T: Movable payload observed only after a successful strong upgrade. A: Movable Defaultable allocator retained until final control cleanup.
Weak.init
pub init()Creates an empty weak observer without allocation.
Weak.init
pub init(Source: readonly Self&)Retains the source control block without retaining its payload. Source: Existing weak observer or empty handle.
Weak.init
pub init(Source: mut Self&&)Transfers one weak lease without retention. Source: Writable observer left empty.
Weak.operator
pub fn operator =(Source: readonly Self&) -> voidRetains source control before releasing the destination lease. Source: Observer to retain; exact self-assignment is unchanged. Return: No value.
Weak.operator
pub fn operator =(Source: mut Self&&) -> voidReleases old control ownership and transfers Source. Source: Observer left empty; exact self-move is unchanged. Return: No value.
Weak.IsEmpty
pub IsEmpty: bool;Reports absence of a control lease, independently of payload expiry. Return: True only for empty/moved-from observers.
Weak.Upgrade
pub readonly fn Upgrade() -> Shared<T, A>?Atomically acquires a strong owner while the payload is still live. Return: New strong owner, or none for an empty/expired observer; no allocation.
Weak.Clear
pub fn Clear() -> voidReleases this weak lease, possibly freeing the final control record. Return: No value; the observer is empty before control cleanup begins.