Struct netsblox_vm::gc::Gc  
source · pub struct Gc<'gc, T>where
    T: 'gc + ?Sized,{ /* private fields */ }Expand description
A garbage collected pointer to a type T. Implements Copy, and is implemented as a plain machine
pointer. You can only allocate Gc pointers through a &Mutation<'gc> inside an arena type,
and through “generativity” such Gc pointers may not escape the arena they were born in or
be stored inside TLS. This, combined with correct Collect implementations, means that Gc
pointers will never be dangling and are always safe to access.
Implementations§
source§impl<'gc, T> Gc<'gc, T>where
    T: 'gc,
 
impl<'gc, T> Gc<'gc, T>where T: 'gc,
source§impl<'gc, T> Gc<'gc, T>where
    T: 'gc + ?Sized,
 
impl<'gc, T> Gc<'gc, T>where T: 'gc + ?Sized,
sourcepub fn as_ref(self) -> &'gc T
 
pub fn as_ref(self) -> &'gc T
Obtains a long-lived reference to the contents of this Gc.
Unlike AsRef or Deref, the returned reference isn’t bound to the Gc itself, and
will stay valid for the entirety of the current arena callback.
pub fn downgrade(this: Gc<'gc, T>) -> GcWeak<'gc, T>
sourcepub fn write(mc: &Mutation<'gc>, gc: Gc<'gc, T>) -> &'gc Write<T>
 
pub fn write(mc: &Mutation<'gc>, gc: Gc<'gc, T>) -> &'gc Write<T>
Triggers a write barrier on this Gc, allowing for further safe mutation.
pub fn ptr_eq(this: Gc<'gc, T>, other: Gc<'gc, T>) -> bool
pub fn as_ptr(gc: Gc<'gc, T>) -> *const T
source§impl<'gc, T> Gc<'gc, RefLock<T>>where
    T: 'gc + ?Sized,
 
impl<'gc, T> Gc<'gc, RefLock<T>>where T: 'gc + ?Sized,
pub fn borrow(self) -> Ref<'gc, T>
pub fn try_borrow(self) -> Result<Ref<'gc, T>, BorrowError>
pub fn borrow_mut(self, mc: &Mutation<'gc>) -> RefMut<'gc, T>
pub fn try_borrow_mut( self, mc: &Mutation<'gc> ) -> Result<RefMut<'gc, T>, BorrowMutError>
Trait Implementations§
source§impl<'gc, T> Collect for Gc<'gc, T>where
    T: 'gc + ?Sized,
 
impl<'gc, T> Collect for Gc<'gc, T>where T: 'gc + ?Sized,
source§fn trace(&self, cc: &Collection)
 
fn trace(&self, cc: &Collection)
Must call 
Collect::trace on all held Gc pointers. If this type holds inner types that
implement Collect, a valid implementation would simply call Collect::trace on all the
held values to ensure this.source§fn needs_trace() -> boolwhere
    Self: Sized,
 
fn needs_trace() -> boolwhere Self: Sized,
As an optimization, if this type can never hold a 
Gc pointer and trace is unnecessary
to call, you may implement this method and return false. The default implementation returns
true, signaling that Collect::trace must be called.source§impl<'gc, C: CustomTypes<S>, S: System<C>> From<Gc<'gc, RefLock<Closure<'gc, C, S>>>> for Value<'gc, C, S>
 
impl<'gc, C: CustomTypes<S>, S: System<C>> From<Gc<'gc, RefLock<Closure<'gc, C, S>>>> for Value<'gc, C, S>
source§impl<'gc, C: CustomTypes<S>, S: System<C>> From<Gc<'gc, RefLock<Entity<'gc, C, S>>>> for Value<'gc, C, S>
 
impl<'gc, C: CustomTypes<S>, S: System<C>> From<Gc<'gc, RefLock<Entity<'gc, C, S>>>> for Value<'gc, C, S>
source§impl<'gc, C: CustomTypes<S>, S: System<C>> From<Gc<'gc, RefLock<VecDeque<Value<'gc, C, S>, Global>>>> for Value<'gc, C, S>
 
impl<'gc, C: CustomTypes<S>, S: System<C>> From<Gc<'gc, RefLock<VecDeque<Value<'gc, C, S>, Global>>>> for Value<'gc, C, S>
impl<'gc, T> Copy for Gc<'gc, T>where T: 'gc + ?Sized,
Auto Trait Implementations§
impl<'gc, T> !RefUnwindSafe for Gc<'gc, T>
impl<'gc, T> !Send for Gc<'gc, T>
impl<'gc, T> !Sync for Gc<'gc, T>
impl<'gc, T: ?Sized> Unpin for Gc<'gc, T>
impl<'gc, T> !UnwindSafe for Gc<'gc, T>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
 
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
 
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more