pub struct Closure<'gc>(/* private fields */);Implementations§
Source§impl<'gc> Closure<'gc>
 
impl<'gc> Closure<'gc>
Sourcepub fn new(
    mc: &Mutation<'gc>,
    proto: FunctionPrototype<'gc>,
    environment: Option<Table<'gc>>,
) -> Result<Closure<'gc>, ClosureError>
 
pub fn new( mc: &Mutation<'gc>, proto: FunctionPrototype<'gc>, environment: Option<Table<'gc>>, ) -> Result<Closure<'gc>, ClosureError>
Create a top-level closure, prototype must not have any upvalues besides _ENV.
pub fn from_parts( mc: &Mutation<'gc>, proto: Gc<'gc, FunctionPrototype<'gc>>, upvalues: Vec<UpValue<'gc>, MetricsAlloc<'gc>>, ) -> Self
pub fn from_inner(inner: Gc<'gc, ClosureInner<'gc>>) -> Self
pub fn into_inner(self) -> Gc<'gc, ClosureInner<'gc>>
Sourcepub fn load(
    ctx: Context<'gc>,
    name: Option<&str>,
    source: impl Read,
) -> Result<Closure<'gc>, PrototypeError>
 
pub fn load( ctx: Context<'gc>, name: Option<&str>, source: impl Read, ) -> Result<Closure<'gc>, PrototypeError>
Compile a top-level closure from source, using the globals table as the _ENV table.
Sourcepub fn load_with_env(
    ctx: Context<'gc>,
    name: Option<&str>,
    source: impl Read,
    env: Table<'gc>,
) -> Result<Closure<'gc>, PrototypeError>
 
pub fn load_with_env( ctx: Context<'gc>, name: Option<&str>, source: impl Read, env: Table<'gc>, ) -> Result<Closure<'gc>, PrototypeError>
Compile a top-level closure from source, using the given table as the _ENV table.
pub fn prototype(self) -> Gc<'gc, FunctionPrototype<'gc>>
pub fn upvalues(self) -> &'gc [UpValue<'gc>]
Trait Implementations§
Source§impl<'gc> Collect for Closure<'gc>
 
impl<'gc> Collect for Closure<'gc>
Source§fn needs_trace() -> bool
 
fn needs_trace() -> bool
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§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§impl<'a, 'gc> IntoValue<'gc> for &'a Closure<'gc>
 
impl<'a, 'gc> IntoValue<'gc> for &'a Closure<'gc>
fn into_value(self, ctx: Context<'gc>) -> Value<'gc>
Source§impl<'gc> IntoValue<'gc> for Closure<'gc>
 
impl<'gc> IntoValue<'gc> for Closure<'gc>
fn into_value(self, _: Context<'gc>) -> Value<'gc>
Source§impl<'gc> Stashable<'gc> for Closure<'gc>
 
impl<'gc> Stashable<'gc> for Closure<'gc>
type Stashed = StashedClosure
fn stash(self, roots: &DynamicRootSet<'gc>, mc: &Mutation<'gc>) -> Self::Stashed
impl<'gc> Copy for Closure<'gc>
impl<'gc> Eq for Closure<'gc>
Auto Trait Implementations§
impl<'gc> Freeze for Closure<'gc>
impl<'gc> !RefUnwindSafe for Closure<'gc>
impl<'gc> !Send for Closure<'gc>
impl<'gc> !Sync for Closure<'gc>
impl<'gc> Unpin for Closure<'gc>
impl<'gc> !UnwindSafe for Closure<'gc>
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