fn try_tuple_like_index_get(target: &Value, index: usize) -> Result<Option<Value>, VmError> {
        let value = match target {
            Value::Unit => None,
            Value::Tuple(tuple) => tuple.borrow_ref()?.get(index).cloned(),
            Value::Vec(vec) => vec.borrow_ref()?.get(index).cloned(),
            Value::Result(result) => {
                let result = result.borrow_ref()?;

                match &*result {
                    Ok(value) if index == 0 => Some(value.clone()),
                    Err(value) if index == 0 => Some(value.clone()),
                    _ => None,
                }
            }
            Value::Option(option) => {
                let option = option.borrow_ref()?;

                match &*option {
                    Some(value) if index == 0 => Some(value.clone()),
                    _ => None,
                }
            }
            Value::GeneratorState(state) => {
                use crate::GeneratorState::*;
                let state = state.borrow_ref()?;

                match &*state {
                    Yielded(value) if index == 0 => Some(value.clone()),
                    Complete(value) if index == 0 => Some(value.clone()),
                    _ => None,
                }
            }
            Value::TupleStruct(tuple_struct) => {
                let tuple_struct = tuple_struct.borrow_ref()?;
                tuple_struct.data().get(index).cloned()
            }
            Value::Variant(variant) => {
                let variant = variant.borrow_ref()?;

                match variant.data() {
                    VariantData::Tuple(tuple) => tuple.get(index).cloned(),
                    _ => return Ok(None),
                }
            }
            _ => return Ok(None),
        };

        let value = match value {
            Some(value) => value,
            None => {
                return Err(VmError::from(VmErrorKind::MissingIndex {
                    target: target.type_info()?,
                    index: VmIntegerRepr::from(index),
                }));
            }
        };

        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_tuple_like_index_get(target: &Value, index: usize) -> Result<Option<Value>, VmError> {
        let value = match target {
            Value::Unit => None,
            Value::Tuple(tuple) => tuple.borrow_ref()?.get(index).cloned(),
            Value::Vec(vec) => vec.borrow_ref()?.get(index).cloned(),
            Value::Result(result) => {
                let result = result.borrow_ref()?;
                match &*result {
                    Ok(value) if index == 0 => Some(value.clone()),
                    Err(value) if index == 0 => Some(value.clone()),
                    _ => None,
                }
            }
            Value::Option(option) => {
                let option = option.borrow_ref()?;
                match &*option {
                    Some(value) if index == 0 => Some(value.clone()),
                    _ => None,
                }
            }
            Value::GeneratorState(state) => {
                use crate::GeneratorState::*;
                let state = state.borrow_ref()?;
                match &*state {
                    Yielded(value) if index == 0 => Some(value.clone()),
                    Complete(value) if index == 0 => Some(value.clone()),
                    _ => None,
                }
            }
            Value::TupleStruct(tuple_struct) => {
                let tuple_struct = tuple_struct.borrow_ref()?;
                tuple_struct.data().get(index).cloned()
            }
            Value::Variant(variant) => {
                let variant = variant.borrow_ref()?;
                match variant.data() {
                    VariantData::Tuple(tuple) => tuple.get(index).cloned(),
                    _ => return Ok(None),
                }
            }
            _ => return Ok(None),
        };
        let value = match value {
            Some(value) => value,
            None => {
                return Err(VmError::from(VmErrorKind::MissingIndex {
                    target: target.type_info()?,
                    index: VmIntegerRepr::from(index),
                }));
            }
        };
        Ok(Some(value))
    }
fn try_tuple_like_index_get ( target : & Value , index : usize ) -> Result < Option < Value > , VmError > { let value = match target { Value :: Unit => None , Value :: Tuple ( tuple ) => tuple . borrow_ref ( ) ? . get ( index ) . cloned ( ) , Value :: Vec ( vec ) => vec . borrow_ref ( ) ? . get ( index ) . cloned ( ) , Value :: Result ( result ) => { let result = result . borrow_ref ( ) ? ; match & * result { Ok ( value ) if index == 0 => Some ( value . clone ( ) ) , Err ( value ) if index == 0 => Some ( value . clone ( ) ) , _ => None , } } Value :: Option ( option ) => { let option = option . borrow_ref ( ) ? ; match & * option { Some ( value ) if index == 0 => Some ( value . clone ( ) ) , _ => None , } } Value :: GeneratorState ( state ) => { use crate :: GeneratorState :: * ; let state = state . borrow_ref ( ) ? ; match & * state { Yielded ( value ) if index == 0 => Some ( value . clone ( ) ) , Complete ( value ) if index == 0 => Some ( value . clone ( ) ) , _ => None , } } Value :: TupleStruct ( tuple_struct ) => { let tuple_struct = tuple_struct . borrow_ref ( ) ? ; tuple_struct . data ( ) . get ( index ) . cloned ( ) } Value :: Variant ( variant ) => { let variant = variant . borrow_ref ( ) ? ; match variant . data ( ) { VariantData :: Tuple ( tuple ) => tuple . get ( index ) . cloned ( ) , _ => return Ok ( None ) , } } _ => return Ok ( None ) , } ; let value = match value { Some ( value ) => value , None => { return Err ( VmError :: from ( VmErrorKind :: MissingIndex { target : target . type_info ( ) ? , index : VmIntegerRepr :: from ( index ) , } ) ) ; } } ; 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
index
usize
target
&Value
index
usize