Struct boa::object::ObjectInitializer
source · [−]pub struct ObjectInitializer<'context> { /* private fields */ }
Expand description
Builder for creating objects with properties.
Examples
let mut context = Context::new();
let object = ObjectInitializer::new(&mut context)
.property(
"hello",
"world",
Attribute::all()
)
.property(
1,
1,
Attribute::all()
)
.function(|_, _, _| Ok(JsValue::undefined()), "func", 0)
.build();
The equivalent in JavaScript would be:
let object = {
hello: "world",
"1": 1,
func: function() {}
}
Implementations
sourceimpl<'context> ObjectInitializer<'context>
impl<'context> ObjectInitializer<'context>
sourcepub fn function<B>(
&mut self,
function: NativeFunction,
binding: B,
length: usize
) -> &mut Selfwhere
B: Into<FunctionBinding>,
pub fn function<B>(
&mut self,
function: NativeFunction,
binding: B,
length: usize
) -> &mut Selfwhere
B: Into<FunctionBinding>,
Add a function to the object.
Trait Implementations
Auto Trait Implementations
impl<'context> !RefUnwindSafe for ObjectInitializer<'context>
impl<'context> !Send for ObjectInitializer<'context>
impl<'context> !Sync for ObjectInitializer<'context>
impl<'context> Unpin for ObjectInitializer<'context>
impl<'context> !UnwindSafe for ObjectInitializer<'context>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more