Skip to main content

Gc

Struct Gc 

Source
pub struct Gc<T: ?Sized> { /* private fields */ }
Expand description

A GC-managed pointer. Copy + Clone (one-machine-word). Replaces GcRef<T>.

Implementations§

Source§

impl<T: Trace + 'static> Gc<T>

Source

pub fn new_uncollected(value: T) -> Self

Allocate a GcBox<T> outside any heap registry. Used by legacy GcRef::new call sites until Phase D-1b migrates them. The returned Gc<T> is reachable only through the caller’s own retention path; without joining a heap owner list, it will never be swept (so effectively leaks until process exit — same as Rc behavior).

Source

pub fn as_trace_ptr(self) -> NonNull<GcBox<dyn Trace>>

Erased heap-list pointer for collector-owned intrusive bookkeeping.

Source§

impl<T: ?Sized> Gc<T>

Source

pub fn ptr_eq(a: Self, b: Self) -> bool

Two Gc<T>s are identity-equal iff they point at the same box.

Source

pub fn identity(self) -> usize

Identity as a usize — usable as a hash table key for “is the same object” lookups.

Source

pub fn is_heap_tracked(self) -> bool

True iff this box is linked into a sweepable heap owner list (HDR_COLLECTED set) — the collector may free it during the owning heap’s lifetime. Detached (new_uncollected) boxes and heap-owned bootstrap (allocate_uncollected) boxes report false.

Source

pub fn is_heap_owned(self) -> bool

True iff some Heap will free this box — during collection (allocate) or at teardown in drop_all (allocate_uncollected). Only detached Gc::new_uncollected boxes report false. Strict-guard mode keys on this: a guard-less weak handle or dropped buffer charge is hazardous for any heap-owned box (a bootstrap box’s weak handle dangles after heap teardown just the same), while the detached process-lifetime path is the sanctioned legacy behavior.

Source

pub fn color(self) -> Color

Source

pub fn set_color(self, color: Color)

Source

pub fn age(self) -> GcAge

Source

pub fn set_age(self, age: GcAge)

Source

pub fn is_finalized(self) -> bool

Source

pub fn set_finalized(self, finalized: bool)

Source

pub fn account_buffer(&self, heap: &Heap, delta: isize)

Charge (delta > 0) or refund (delta < 0) delta bytes of this object’s owned heap buffers against the pacer, keeping header.size as the single source of truth for what sweep will refund.

No-op when delta == 0 or when this box is not on a heap owner list (collected == false): an uncollected box is never swept, so charging it would permanently inflate the byte counter. On the collected path, header.size and the heap’s byte counter move together, so after sweep frees this box it refunds exactly the bytes that were charged here.

Trait Implementations§

Source§

impl<T: ?Sized> AsRef<T> for Gc<T>

Source§

fn as_ref(&self) -> &T

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<T: ?Sized> Clone for Gc<T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: ?Sized> Copy for Gc<T>

Source§

impl<T: ?Sized> Debug for Gc<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: ?Sized> Deref for Gc<T>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &T

Dereferences the value.
Source§

impl<T: ?Sized> Eq for Gc<T>

Source§

impl<T: ?Sized> Hash for Gc<T>

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T: ?Sized> PartialEq for Gc<T>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<T: Trace + 'static> Trace for Gc<T>

Gc<T> is itself traceable: marking it forwards to the contained T.

Source§

fn trace(&self, m: &mut Marker)

Source§

fn type_name(&self) -> &'static str

Concrete Rust type name for diagnostic/testC telemetry (Heap::type_name_count). Collector behavior must not branch on this. The default covers container blanket impls, which are never GC-boxed directly; concrete runtime types override it with std::any::type_name::<Self>().

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for Gc<T>

§

impl<T> !Send for Gc<T>

§

impl<T> !Sync for Gc<T>

§

impl<T> !UnwindSafe for Gc<T>

§

impl<T> Freeze for Gc<T>
where T: ?Sized,

§

impl<T> Unpin for Gc<T>
where T: Unpin + ?Sized,

§

impl<T> UnsafeUnpin for Gc<T>
where T: ?Sized,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.