[][src]Struct zub::vm::gc::Heap

pub struct Heap<T> { /* fields omitted */ }

Implementations

impl<T: Trace<T>> Heap<T>[src]

pub fn new() -> Self[src]

Create an empty heap.

pub fn insert_temp(&mut self, object: T) -> Handle<T>[src]

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

pub fn insert(&mut self, object: T) -> Rooted<T>[src]

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

pub fn make_rooted(&mut self, handle: impl AsRef<Handle<T>>) -> Rooted<T>[src]

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

pub fn len(&self) -> usize[src]

Count the number of heap-allocated objects in this heap

pub fn contains(&self, handle: impl AsRef<Handle<T>>) -> bool[src]

Return true if the heap contains the specified handle

pub fn get(&self, handle: impl AsRef<Handle<T>>) -> Option<&T>[src]

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

pub unsafe fn get_unchecked(&self, handle: impl AsRef<Handle<T>>) -> &T[src]

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.

pub fn get_mut(&mut self, handle: impl AsRef<Handle<T>>) -> Option<&mut T>[src]

Get a mutable reference to a heap object

pub fn get_mut_unchecked(&mut self, handle: impl AsRef<Handle<T>>) -> &mut T[src]

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.

pub fn clean_excluding(
    &mut self,
    excluding: impl IntoIterator<Item = Handle<T>>
)
[src]

pub fn clean(&mut self)[src]

Clean orphaned objects from the heap.

Trait Implementations

impl<T: Clone> Clone for Heap<T>[src]

impl<T> Default for Heap<T>[src]

impl<T> Drop for Heap<T>[src]

Auto Trait Implementations

impl<T> !RefUnwindSafe for Heap<T>

impl<T> !Send for Heap<T>

impl<T> !Sync for Heap<T>

impl<T> Unpin for Heap<T>

impl<T> !UnwindSafe for Heap<T>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.