Struct corundum::prc::Weak[][src]

pub struct Weak<T: PSafe + ?Sized, A: MemPool> { /* fields omitted */ }
Expand description

Weak is a version of Prc that holds a non-owning reference to the managed allocation. The allocation is accessed by calling upgrade on the Weak pointer, which returns an Option<Prc<T>>.

Since a Weak reference does not count towards ownership, it will not prevent the value stored in the allocation from being dropped, and Weak itself makes no guarantees about the value still being present. Thus it may return None when upgraded. Note however that a Weak reference does prevent the allocation itself (the backing store) from being deallocated.

A Weak pointer is useful for keeping a temporary reference to the allocation managed by Prc without preventing its inner value from being dropped. It is also used to prevent circular references between Prc pointers, since mutual owning references would never allow either Prc to be dropped. For example, a tree could have strong Prc pointers from parent nodes to children, and Weak pointers from children back to their parents.

The typical way to obtain a Weak pointer is to call Prc::downgrade.

Implementations

Creates a new dangling weak pointer

Trait Implementations

Formats the value using the given formatter. Read more

Executes the destructor for this type. Read more

Performs copy-assignment from source. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.