Struct scoped_gc::Gc

source ·
pub struct Gc<'gc, T: Trace + 'gc> { /* private fields */ }
Expand description

A smart pointer to a value managed by a garbage-collector

This pointer can be created either by allocating a new garbage-collected value using the GcScope::alloc method or by cloning an existing Gc pointer with Gc::clone. This pointer can only be used during the lifetime of the corresponding garbage-collected scope (represented by the lifetime 'gc).

By default, a Gc pointer acts as a root for its value: as long as the Gc is on the stack its value is kept alive. A Gc is unrooted only when it is moved (transitively) inside another Gc.

Trait Implementations

Creates a new Gc pointer for the same value.

It is recommended to use it as Gc::clone(&gc) instead of gc.clone() to avoid confusion with the clone method of the inner value.

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

The Deref implementation allows to use the value’s methods directly on the Gc pointer.

The resulting type after dereferencing.
Dereferences the value.
Executes the destructor for this type. Read more

Marks the value in the GcBox as reachable.

The mark signal will be propagated further in the object graph unless the box was already marked (to avoid infinite loops on cycles, or redundant traversals).

Tags this Gc pointer as a root for its value.

Untags this Gc pointer as a root for its value.

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 resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
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.