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’s allgc chain, it will never be swept (so effectively leaks until process exit — same as Rc behavior).

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 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 allgc chain (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> 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> 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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
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§

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

Source§

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

Auto Trait Implementations§

§

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

§

impl<T> !RefUnwindSafe for Gc<T>

§

impl<T> !Send for Gc<T>

§

impl<T> !Sync for Gc<T>

§

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

§

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

§

impl<T> !UnwindSafe for Gc<T>

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.