pub struct FunctionBuilder<'context> { /* private fields */ }
Expand description
Builder for creating native function objects
Implementations§
Source§impl<'context> FunctionBuilder<'context>
impl<'context> FunctionBuilder<'context>
Sourcepub fn native(context: &'context mut Context, function: NativeFunction) -> Self
pub fn native(context: &'context mut Context, function: NativeFunction) -> Self
Create a new FunctionBuilder
for creating a native function.
Sourcepub fn closure<F>(context: &'context mut Context, function: F) -> Self
pub fn closure<F>(context: &'context mut Context, function: F) -> Self
Create a new FunctionBuilder
for creating a closure function.
Sourcepub fn closure_with_captures<F, C>(
context: &'context mut Context,
function: F,
captures: C,
) -> Self
pub fn closure_with_captures<F, C>( context: &'context mut Context, function: F, captures: C, ) -> Self
Create a new closure function with additional captures.
§Note
You can only move variables that implement Debug + Any + Trace + Clone
.
In other words, only NativeObject + Clone
objects are movable.
Sourcepub fn name<N>(&mut self, name: N) -> &mut Self
pub fn name<N>(&mut self, name: N) -> &mut Self
Specify the name property of object function object.
The default is ""
(empty string).
Sourcepub fn length(&mut self, length: usize) -> &mut Self
pub fn length(&mut self, length: usize) -> &mut Self
Specify the length property of object function object.
How many arguments this function takes.
The default is 0
.
Sourcepub fn constructable(&mut self, yes: bool) -> &mut Self
pub fn constructable(&mut self, yes: bool) -> &mut Self
Specify the whether the object function object can be called with new
keyword.
The default is false
.
Trait Implementations§
Auto Trait Implementations§
impl<'context> !Freeze for FunctionBuilder<'context>
impl<'context> !RefUnwindSafe for FunctionBuilder<'context>
impl<'context> !Send for FunctionBuilder<'context>
impl<'context> !Sync for FunctionBuilder<'context>
impl<'context> Unpin for FunctionBuilder<'context>
impl<'context> !UnwindSafe for FunctionBuilder<'context>
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