Skip to main content

Gc

Struct Gc 

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

Copy handle to a heap-allocated GC-managed object. Layout is a single NonNull<T>; the GC walks reachability via root scanning and intrusive linkage on GcHeader, not via reference counts.

Implementations§

Source§

impl<T> Gc<T>

Source

pub fn as_ptr(self) -> *mut T

Raw pointer to the referent. Always non-null; valid for the lifetime of the Heap that allocated it as long as the object is reachable.

Source

pub fn ptr_eq(self, other: Gc<T>) -> bool

Pointer-identity equality (PUC rawequal for reference types).

Source§

impl Gc<LuaStr>

Inline-bytes access MUST go through a pointer carrying the provenance of the original allocation — a &LuaStr only covers the header, so deriving the tail from it is UB (caught by miri). Gc stores the allocation pointer, hence these live on Gc<LuaStr>.

Source

pub fn as_bytes(&self) -> &[u8]

Borrow the underlying bytes of this Lua string.

Source

pub fn hash(&self) -> u32

Cached hash of the string (computed lazily for long strings).

Trait Implementations§

Source§

impl<T> 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> Copy for Gc<T>

Source§

impl<T> Debug for Gc<T>

Source§

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

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

impl<T> Deref for Gc<T>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &T

Dereferences the value.
Source§

impl IntoValue for Gc<Table>

Source§

fn into_value(self, _vm: &mut Vm) -> Value

Convert self to a Lua Value, interning strings or allocating other GC-managed types via vm.heap as needed.
Source§

impl IntoValue for Gc<LuaClosure>

Source§

fn into_value(self, _vm: &mut Vm) -> Value

Convert self to a Lua Value, interning strings or allocating other GC-managed types via vm.heap as needed.
Source§

impl IntoValue for Gc<NativeClosure>

Source§

fn into_value(self, _vm: &mut Vm) -> Value

Convert self to a Lua Value, interning strings or allocating other GC-managed types via vm.heap as needed.

Auto Trait Implementations§

§

impl<T> !Send for Gc<T>

§

impl<T> !Sync for Gc<T>

§

impl<T> Freeze for Gc<T>

§

impl<T> RefUnwindSafe for Gc<T>
where T: RefUnwindSafe,

§

impl<T> Unpin for Gc<T>

§

impl<T> UnsafeUnpin for Gc<T>

§

impl<T> UnwindSafe for Gc<T>
where T: RefUnwindSafe,

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.