Struct zerogc::vec::GcVec [−][src]
pub struct GcVec<'gc, T: GcSafe, Ctx: GcSimpleAlloc> { pub context: &'gc Ctx, pub raw: GcRawVec<'gc, T, Ctx::Id>, }
Expand description
A version of Vec for use with garbage collectors.
This is simply a thin wrapper around [RawGcVec] that also contains a reference to the owning [GcContext].
Fields
context: &'gc Ctx
A reference to the owning GcContext
raw: GcRawVec<'gc, T, Ctx::Id>
The underlying [RawGcVec], which actually manages the memory
Implementations
Convert this vector into its underlying GcRawVec
Reserve enough capacity for the specified number of additional elements.
Extend the vector with elements copied from the specified slice
Methods from Deref<Target = GcRawVec<'gc, T, Ctx::Id>>
pub fn with_context_mut<Ctx, F, R>(&mut self, ctx: &'gc Ctx, func: F) -> R where
Ctx: GcSimpleAlloc<Id = Id>,
F: FnOnce(&mut GcVec<'gc, T, Ctx>) -> R,
pub fn with_context_mut<Ctx, F, R>(&mut self, ctx: &'gc Ctx, func: F) -> R where
Ctx: GcSimpleAlloc<Id = Id>,
F: FnOnce(&mut GcVec<'gc, T, Ctx>) -> R,
View this [RawGcVec] as a GcVec for the duration of the specified closure, with an implicit reference to the specified [GcContext]
pub fn with_context<Ctx, F, R>(&self, ctx: &'gc Ctx, func: F) -> R where
Ctx: GcSimpleAlloc<Id = Id>,
F: FnOnce(&GcVec<'gc, T, Ctx>) -> R,
pub fn with_context<Ctx, F, R>(&self, ctx: &'gc Ctx, func: F) -> R where
Ctx: GcSimpleAlloc<Id = Id>,
F: FnOnce(&GcVec<'gc, T, Ctx>) -> R,
View this [RawGcVec] as a GcVec for the duration of the specified closure
Push a value onto this vector, returning an error if there is insufficient space.
Get a mutable reference to the raw represnetation of this vector
Safety
The user must preserve the validity of the underlying representation.
Interpret this vector as a slice
Because the length may change, this is bound to the lifetime of the current value.
Trait Implementations
Whether this type needs to be traced by the garbage collector. Read more
If this type needs a destructor run. Read more
Visit each field in this type Read more
unsafe fn visit_inside_gc<'actual_gc, Visitor, ActualId>(
gc: &mut Gc<'actual_gc, Self, ActualId>,
visitor: &mut Visitor
) -> Result<(), Visitor::Err> where
Visitor: GcVisitor,
ActualId: CollectorId,
Self: GcSafe + 'actual_gc,
unsafe fn visit_inside_gc<'actual_gc, Visitor, ActualId>(
gc: &mut Gc<'actual_gc, Self, ActualId>,
visitor: &mut Visitor
) -> Result<(), Visitor::Err> where
Visitor: GcVisitor,
ActualId: CollectorId,
Self: GcSafe + 'actual_gc,
Visit this object, assuming its already inside a GC pointer. Read more