fn try_tuple_like_index_set(
        target: &Value,
        index: usize,
        value: Value,
    ) -> Result<bool, VmError> {
        match target {
            Value::Unit => Ok(false),
            Value::Tuple(tuple) => {
                let mut tuple = tuple.borrow_mut()?;

                if let Some(target) = tuple.get_mut(index) {
                    *target = value;
                    return Ok(true);
                }

                Ok(false)
            }
            Value::Vec(vec) => {
                let mut vec = vec.borrow_mut()?;

                if let Some(target) = vec.get_mut(index) {
                    *target = value;
                    return Ok(true);
                }

                Ok(false)
            }
            Value::Result(result) => {
                let mut result = result.borrow_mut()?;

                let target = match &mut *result {
                    Ok(ok) if index == 0 => ok,
                    Err(err) if index == 0 => err,
                    _ => return Ok(false),
                };

                *target = value;
                Ok(true)
            }
            Value::Option(option) => {
                let mut option = option.borrow_mut()?;

                let target = match &mut *option {
                    Some(some) if index == 0 => some,
                    _ => return Ok(false),
                };

                *target = value;
                Ok(true)
            }
            Value::TupleStruct(tuple_struct) => {
                let mut tuple_struct = tuple_struct.borrow_mut()?;

                if let Some(target) = tuple_struct.get_mut(index) {
                    *target = value;
                    return Ok(true);
                }

                Ok(false)
            }
            Value::Variant(variant) => {
                let mut variant = variant.borrow_mut()?;

                if let VariantData::Tuple(data) = variant.data_mut() {
                    if let Some(target) = data.get_mut(index) {
                        *target = value;
                        return Ok(true);
                    }
                }

                Ok(false)
            }
            _ => Ok(false),
        }
    }
/// 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_set(
        target: &Value,
        index: usize,
        value: Value,
    ) -> Result<bool, VmError> {
        match target {
            Value::Unit => Ok(false),
            Value::Tuple(tuple) => {
                let mut tuple = tuple.borrow_mut()?;
                if let Some(target) = tuple.get_mut(index) {
                    *target = value;
                    return Ok(true);
                }
                Ok(false)
            }
            Value::Vec(vec) => {
                let mut vec = vec.borrow_mut()?;
                if let Some(target) = vec.get_mut(index) {
                    *target = value;
                    return Ok(true);
                }
                Ok(false)
            }
            Value::Result(result) => {
                let mut result = result.borrow_mut()?;
                let target = match &mut *result {
                    Ok(ok) if index == 0 => ok,
                    Err(err) if index == 0 => err,
                    _ => return Ok(false),
                };
                *target = value;
                Ok(true)
            }
            Value::Option(option) => {
                let mut option = option.borrow_mut()?;
                let target = match &mut *option {
                    Some(some) if index == 0 => some,
                    _ => return Ok(false),
                };
                *target = value;
                Ok(true)
            }
            Value::TupleStruct(tuple_struct) => {
                let mut tuple_struct = tuple_struct.borrow_mut()?;
                if let Some(target) = tuple_struct.get_mut(index) {
                    *target = value;
                    return Ok(true);
                }
                Ok(false)
            }
            Value::Variant(variant) => {
                let mut variant = variant.borrow_mut()?;
                if let VariantData::Tuple(data) = variant.data_mut() {
                    if let Some(target) = data.get_mut(index) {
                        *target = value;
                        return Ok(true);
                    }
                }
                Ok(false)
            }
            _ => Ok(false),
        }
    }
fn try_tuple_like_index_set ( target : & Value , index : usize , value : Value , ) -> Result < bool , VmError > { match target { Value :: Unit => Ok ( false ) , Value :: Tuple ( tuple ) => { let mut tuple = tuple . borrow_mut ( ) ? ; if let Some ( target ) = tuple . get_mut ( index ) { * target = value ; return Ok ( true ) ; } Ok ( false ) } Value :: Vec ( vec ) => { let mut vec = vec . borrow_mut ( ) ? ; if let Some ( target ) = vec . get_mut ( index ) { * target = value ; return Ok ( true ) ; } Ok ( false ) } Value :: Result ( result ) => { let mut result = result . borrow_mut ( ) ? ; let target = match & mut * result { Ok ( ok ) if index == 0 => ok , Err ( err ) if index == 0 => err , _ => return Ok ( false ) , } ; * target = value ; Ok ( true ) } Value :: Option ( option ) => { let mut option = option . borrow_mut ( ) ? ; let target = match & mut * option { Some ( some ) if index == 0 => some , _ => return Ok ( false ) , } ; * target = value ; Ok ( true ) } Value :: TupleStruct ( tuple_struct ) => { let mut tuple_struct = tuple_struct . borrow_mut ( ) ? ; if let Some ( target ) = tuple_struct . get_mut ( index ) { * target = value ; return Ok ( true ) ; } Ok ( false ) } Value :: Variant ( variant ) => { let mut variant = variant . borrow_mut ( ) ? ; if let VariantData :: Tuple ( data ) = variant . data_mut ( ) { if let Some ( target ) = data . get_mut ( index ) { * target = value ; return Ok ( true ) ; } } Ok ( false ) } _ => Ok ( false ) , } }
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
value
Value
target
&Value
index
usize
value
Value