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

pub struct ObjectInitializer<'context> { /* fields omitted */ }

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(Value::undefined()), "func", 0)
    .build();

The equivalent in JavaScript would be:

let object = {
    hello: "world",
    "1": 1,
    func: function() {}
}

Implementations

impl<'context> ObjectInitializer<'context>[src]

pub fn new(context: &'context mut Context) -> Self[src]

Create a new ObjectBuilder.

pub fn function<B>(
    &mut self,
    function: NativeFunction,
    binding: B,
    length: usize
) -> &mut Self where
    B: Into<FunctionBinding>, 
[src]

Add a function to the object.

pub fn property<K, V>(
    &mut self,
    key: K,
    value: V,
    attribute: Attribute
) -> &mut Self where
    K: Into<PropertyKey>,
    V: Into<Value>, 
[src]

Add a property to the object.

pub fn build(&mut self) -> GcObject[src]

Build the object.

Trait Implementations

impl<'context> Debug for ObjectInitializer<'context>[src]

Auto Trait Implementations

impl<'context> !RefUnwindSafe for ObjectInitializer<'context>[src]

impl<'context> !Send for ObjectInitializer<'context>[src]

impl<'context> !Sync for ObjectInitializer<'context>[src]

impl<'context> Unpin for ObjectInitializer<'context>[src]

impl<'context> !UnwindSafe for ObjectInitializer<'context>[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,