[−][src]Struct boa::object::ObjectInitializer
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]
&mut self,
function: NativeFunction,
binding: B,
length: usize
) -> &mut Self where
B: Into<FunctionBinding>,
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]
&mut self,
key: K,
value: V,
attribute: Attribute
) -> &mut Self where
K: Into<PropertyKey>,
V: Into<Value>,
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,