fn try_tuple_like_index_get_mut(
        target: &Value,
        index: usize,
    ) -> Result<Option<BorrowMut<'_, Value>>, VmError> {
        let value = match target {
            Value::Unit => None,
            Value::Tuple(tuple) => {
                let tuple = tuple.borrow_mut()?;

                BorrowMut::try_map(tuple, |tuple| tuple.get_mut(index))
            }
            Value::Vec(vec) => {
                let vec = vec.borrow_mut()?;

                BorrowMut::try_map(vec, |vec| vec.get_mut(index))
            }
            Value::Result(result) => {
                let result = result.borrow_mut()?;

                BorrowMut::try_map(result, |result| match result {
                    Ok(value) if index == 0 => Some(value),
                    Err(value) if index == 0 => Some(value),
                    _ => None,
                })
            }
            Value::Option(option) => {
                let option = option.borrow_mut()?;

                BorrowMut::try_map(option, |option| match option {
                    Some(value) if index == 0 => Some(value),
                    _ => None,
                })
            }
            Value::GeneratorState(state) => {
                use crate::GeneratorState::*;
                let state = state.borrow_mut()?;

                BorrowMut::try_map(state, |state| match state {
                    Yielded(value) if index == 0 => Some(value),
                    Complete(value) if index == 0 => Some(value),
                    _ => None,
                })
            }
            Value::TupleStruct(tuple_struct) => {
                let tuple_struct = tuple_struct.borrow_mut()?;

                BorrowMut::try_map(tuple_struct, |tuple_struct| tuple_struct.get_mut(index))
            }
            Value::Variant(variant) => {
                let variant = variant.borrow_mut()?;

                BorrowMut::try_map(variant, |variant| match variant.data_mut() {
                    VariantData::Tuple(tuple) => tuple.get_mut(index),
                    _ => 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 mutable value out of a tuple-like value.
Implementation of getting a mutable value out of a tuple-like value.
Implementation of getting a mutable value out of a tuple - like value .
fn try_tuple_like_index_get_mut(
        target: &Value,
        index: usize,
    ) -> Result<Option<BorrowMut<'_, Value>>, VmError> {
        let value = match target {
            Value::Unit => None,
            Value::Tuple(tuple) => {
                let tuple = tuple.borrow_mut()?;
                BorrowMut::try_map(tuple, |tuple| tuple.get_mut(index))
            }
            Value::Vec(vec) => {
                let vec = vec.borrow_mut()?;
                BorrowMut::try_map(vec, |vec| vec.get_mut(index))
            }
            Value::Result(result) => {
                let result = result.borrow_mut()?;
                BorrowMut::try_map(result, |result| match result {
                    Ok(value) if index == 0 => Some(value),
                    Err(value) if index == 0 => Some(value),
                    _ => None,
                })
            }
            Value::Option(option) => {
                let option = option.borrow_mut()?;
                BorrowMut::try_map(option, |option| match option {
                    Some(value) if index == 0 => Some(value),
                    _ => None,
                })
            }
            Value::GeneratorState(state) => {
                use crate::GeneratorState::*;
                let state = state.borrow_mut()?;
                BorrowMut::try_map(state, |state| match state {
                    Yielded(value) if index == 0 => Some(value),
                    Complete(value) if index == 0 => Some(value),
                    _ => None,
                })
            }
            Value::TupleStruct(tuple_struct) => {
                let tuple_struct = tuple_struct.borrow_mut()?;
                BorrowMut::try_map(tuple_struct, |tuple_struct| tuple_struct.get_mut(index))
            }
            Value::Variant(variant) => {
                let variant = variant.borrow_mut()?;
                BorrowMut::try_map(variant, |variant| match variant.data_mut() {
                    VariantData::Tuple(tuple) => tuple.get_mut(index),
                    _ => 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_mut ( target : & Value , index : usize , ) -> Result < Option < BorrowMut < ' _ , Value > > , VmError > { let value = match target { Value :: Unit => None , Value :: Tuple ( tuple ) => { let tuple = tuple . borrow_mut ( ) ? ; BorrowMut :: try_map ( tuple , | tuple | tuple . get_mut ( index ) ) } Value :: Vec ( vec ) => { let vec = vec . borrow_mut ( ) ? ; BorrowMut :: try_map ( vec , | vec | vec . get_mut ( index ) ) } Value :: Result ( result ) => { let result = result . borrow_mut ( ) ? ; BorrowMut :: try_map ( result , | result | match result { Ok ( value ) if index == 0 => Some ( value ) , Err ( value ) if index == 0 => Some ( value ) , _ => None , } ) } Value :: Option ( option ) => { let option = option . borrow_mut ( ) ? ; BorrowMut :: try_map ( option , | option | match option { Some ( value ) if index == 0 => Some ( value ) , _ => None , } ) } Value :: GeneratorState ( state ) => { use crate :: GeneratorState :: * ; let state = state . borrow_mut ( ) ? ; BorrowMut :: try_map ( state , | state | match state { Yielded ( value ) if index == 0 => Some ( value ) , Complete ( value ) if index == 0 => Some ( value ) , _ => None , } ) } Value :: TupleStruct ( tuple_struct ) => { let tuple_struct = tuple_struct . borrow_mut ( ) ? ; BorrowMut :: try_map ( tuple_struct , | tuple_struct | tuple_struct . get_mut ( index ) ) } Value :: Variant ( variant ) => { let variant = variant . borrow_mut ( ) ? ; BorrowMut :: try_map ( variant , | variant | match variant . data_mut ( ) { VariantData :: Tuple ( tuple ) => tuple . get_mut ( index ) , _ => 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 mutable value out of a tuple-like value.
Implementation of getting a mutable value out of a tuple - like value .
target
&Value
index
usize
target
&Value
index
usize