pub struct Object(/* private fields */);
Expand description
A type representing a JavaScript object.
Implementations§
Source§impl Object
impl Object
Sourcepub fn to_iter(&self) -> impl ExactSizeIterator<Item = (String, Value)>
pub fn to_iter(&self) -> impl ExactSizeIterator<Item = (String, Value)>
Retrieves an iterator over this object’s keys and values.
When called, this method will pull all the objecy’s keys and values from JavaScript, then return an iterator which accesses them in pairs.
§Example:
use stdweb::{ js, unstable::TryInto, Object };
let obj: Object = js!( return { [1]: 2 } ).try_into()?;
let map: HashMap< i32, i32 > = obj
.to_iter()
.map( |(k, v)| Ok( ( k.parse()?, v.try_into()? ) ) )
.collect::< Result< _, Box< dyn std::error::Error > > >()?;
assert_eq!( map[ &1 ], 2 );
panic!("ahhh");
Trait Implementations§
Source§impl InstanceOf for Object
impl InstanceOf for Object
Source§impl ReferenceType for Object
impl ReferenceType for Object
Source§unsafe fn from_reference_unchecked(reference: Reference) -> Self
unsafe fn from_reference_unchecked(reference: Reference) -> Self
Converts a given reference into a concrete reference-like wrapper.
Doesn’t do any type checking; highly unsafe to use!
Source§impl<E: Into<ConversionError>, V: TryFrom<Value, Error = E>> TryFrom<Object> for BTreeMap<String, V>
impl<E: Into<ConversionError>, V: TryFrom<Value, Error = E>> TryFrom<Object> for BTreeMap<String, V>
Source§impl<E: Into<ConversionError>, V: TryFrom<Value, Error = E>> TryFrom<Object> for HashMap<String, V>
impl<E: Into<ConversionError>, V: TryFrom<Value, Error = E>> TryFrom<Object> for HashMap<String, V>
impl Eq for Object
impl JsSerialize for Object
impl StructuralPartialEq for Object
Auto Trait Implementations§
impl Freeze for Object
impl RefUnwindSafe for Object
impl Send for Object
impl Sync for Object
impl Unpin for Object
impl UnwindSafe for Object
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