pub fn expect_instance(&self, constructor: &str, heap: &Heap) -> Result<(), Exception> {
        let ctrval = (heap.scope())
            .get_value(constructor)
            .ok_or(Exception::ReferenceNotFound(Identifier::from(constructor)))?;

        let ctrref = ctrval.to_ref()?;
        match self.isinstance(ctrref, heap)? {
            true => Ok(()),
            false => {
                let what = Interpreted::from(*self);
                let of = constructor.to_string();
                Err(Exception::TypeErrorInstanceRequired(what, of))
            }
        }
    }
/// Check if the object behind the reference `self` has a prototype of `constructor`.
/// ```
/// # use slothjs::{JSObject, Heap};
/// # let mut heap = Heap::new();
/// let array_ref = heap.alloc(JSObject::from_array(vec![]));
/// array_ref.expect_instance("Array", &heap).unwrap();
/// ```
Check if the object behind the reference `self` has a prototype of `constructor`.
Check if the object behind the reference ` self ` has a prototype of ` constructor ` .
pub fn expect_instance(&self, constructor: &str, heap: &Heap) -> Result<(), Exception> {
        let ctrval = (heap.scope())
            .get_value(constructor)
            .ok_or(Exception::ReferenceNotFound(Identifier::from(constructor)))?;
        let ctrref = ctrval.to_ref()?;
        match self.isinstance(ctrref, heap)? {
            true => Ok(()),
            false => {
                let what = Interpreted::from(*self);
                let of = constructor.to_string();
                Err(Exception::TypeErrorInstanceRequired(what, of))
            }
        }
    }
pub fn expect_instance ( & self , constructor : & str , heap : & Heap ) -> Result < ( ) , Exception > { let ctrval = ( heap . scope ( ) ) . get_value ( constructor ) . ok_or ( Exception :: ReferenceNotFound ( Identifier :: from ( constructor ) ) ) ? ; let ctrref = ctrval . to_ref ( ) ? ; match self . isinstance ( ctrref , heap ) ? { true => Ok ( ( ) ) , false => { let what = Interpreted :: from ( * self ) ; let of = constructor . to_string ( ) ; Err ( Exception :: TypeErrorInstanceRequired ( what , of ) ) } } }
Check if the object behind the reference `self` has a prototype of `constructor`.
Check if the object behind the reference ` self ` has a prototype of ` constructor ` .
&self
constructor
&str
heap
&Heap
&self
constructor
&str
heap
&Heap
use slothjs::{jsobject, heap};
None
let mut heap = heap::new();
let array_ref = heap.alloc(JSObject::from_array(vec![]));
array_ref.expect_instance("Array", &heap).unwrap();
```
let array_ref = heap . alloc ( JSObject :: from_array ( vec! [] )) ; array_ref . expect_instance ( " Array " &heap ) . unwrap () ; ` ` `