fn try_object_like_index_get(target: &Value, field: &str) -> Result<Option<Value>, VmError> {
        let value = match &target {
            Value::Object(target) => target.borrow_ref()?.get(field).cloned(),
            Value::Struct(target) => target.borrow_ref()?.get(field).cloned(),
            Value::Variant(variant) => match variant.borrow_ref()?.data() {
                VariantData::Struct(target) => target.get(field).cloned(),
                _ => return Ok(None),
            },
            _ => return Ok(None),
        };

        let value = match value {
            Some(value) => value,
            None => {
                return Err(VmError::from(VmErrorKind::MissingField {
                    target: target.type_info()?,
                    field: field.to_owned(),
                }));
            }
        };

        Ok(Some(value))
    }
/// Implementation of getting a string index on an object-like type.
Implementation of getting a string index on an object-like type.
Implementation of getting a string index on an object - like type .
fn try_object_like_index_get(target: &Value, field: &str) -> Result<Option<Value>, VmError> {
        let value = match &target {
            Value::Object(target) => target.borrow_ref()?.get(field).cloned(),
            Value::Struct(target) => target.borrow_ref()?.get(field).cloned(),
            Value::Variant(variant) => match variant.borrow_ref()?.data() {
                VariantData::Struct(target) => target.get(field).cloned(),
                _ => return Ok(None),
            },
            _ => return Ok(None),
        };
        let value = match value {
            Some(value) => value,
            None => {
                return Err(VmError::from(VmErrorKind::MissingField {
                    target: target.type_info()?,
                    field: field.to_owned(),
                }));
            }
        };
        Ok(Some(value))
    }
fn try_object_like_index_get ( target : & Value , field : & str ) -> Result < Option < Value > , VmError > { let value = match & target { Value :: Object ( target ) => target . borrow_ref ( ) ? . get ( field ) . cloned ( ) , Value :: Struct ( target ) => target . borrow_ref ( ) ? . get ( field ) . cloned ( ) , Value :: Variant ( variant ) => match variant . borrow_ref ( ) ? . data ( ) { VariantData :: Struct ( target ) => target . get ( field ) . cloned ( ) , _ => return Ok ( None ) , } , _ => return Ok ( None ) , } ; let value = match value { Some ( value ) => value , None => { return Err ( VmError :: from ( VmErrorKind :: MissingField { target : target . type_info ( ) ? , field : field . to_owned ( ) , } ) ) ; } } ; Ok ( Some ( value ) ) }
Implementation of getting a string index on an object-like type.
Implementation of getting a string index on an object - like type .
target
&Value
field
&str
target
&Value
field
&str