Struct boa::object::ObjectInitializer[][src]

pub struct ObjectInitializer<'context> { /* fields omitted */ }
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

Create a new ObjectBuilder.

Add a function to the object.

Add a property to the object.

Build the object.

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.