pub struct Heap<T> { /* private fields */ }
Expand description

A heap for storing objects.

Heap is the centre of broom’s universe. It’s the singleton through with manipulation of objects occurs. It can be used to create, access, mutate and garbage-collect objects.

Note that heaps, and the objects associated with them, are not compatible: this means that you may not create trace routes (see Trace) that cross the boundary between different heaps.

Implementations

Create an empty heap.

Adds a new object to this heap that will be cleared upon the next garbage collection, if not attached to the object tree.

Adds a new object to this heap that will not be cleared by garbage collection until all rooted handles have been dropped.

Upgrade a handle (that will be cleared by the garbage collector) into a rooted handle (that will not).

Count the number of heap-allocated objects in this heap

Return true if the heap contains the specified handle

Get a reference to a heap object if it exists on this heap.

Get a reference to a heap object without checking whether it is still alive or that it belongs to this heap.

If either invariant is not upheld, calling this function results in undefined behaviour.

Get a mutable reference to a heap object

Get a mutable reference to a heap object without first checking that it is still alive or that it belongs to this heap.

If either invariant is not upheld, calling this function results in undefined behaviour. Provided they are upheld, this function provides zero-cost access.

Clean orphaned objects from the heap, excluding those that can be reached from the given handle iterator.

This function is useful in circumstances in which you wish to keep certain items alive over a garbage collection without the addition cost of a Rooted handle. An example of this might be stack items in a garbage-collected language

Clean orphaned objects from the heap.

Trait Implementations

Returns the “default value” for a type. Read more
Executes the destructor for this type. 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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

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.