diff --git a/src/dynamic.rs b/src/dynamic.rs index 93e6d533..887e73d1 100644 --- a/src/dynamic.rs +++ b/src/dynamic.rs @@ -1447,9 +1447,9 @@ impl Dynamic { /// Exported under the `decimal` feature only. #[cfg(feature = "decimal")] #[inline(always)] - pub fn as_decimal(self) -> Result { - match self.0 { - Union::Decimal(n, _) => Ok(*n), + pub fn as_decimal(&self) -> Result { + match &self.0 { + Union::Decimal(n, _) => Ok(**n), #[cfg(not(feature = "no_closure"))] Union::Shared(_, _) => self.read_lock().map(|v| *v).ok_or_else(|| self.type_name()), _ => Err(self.type_name()), diff --git a/src/fn_builtin.rs b/src/fn_builtin.rs index 28a7283c..b81cd500 100644 --- a/src/fn_builtin.rs +++ b/src/fn_builtin.rs @@ -946,27 +946,32 @@ pub fn get_builtin_op_assignment_fn( match op { "+=" => { return Some(|_, args| { - Ok((*args[0].write_lock::().unwrap() += get_y(args)).into()) + let y = get_y(args); + Ok((*args[0].write_lock::().unwrap() += y).into()) }) } "-=" => { return Some(|_, args| { - Ok((*args[0].write_lock::().unwrap() -= get_y(args)).into()) + let y = get_y(args); + Ok((*args[0].write_lock::().unwrap() -= y).into()) }) } "*=" => { return Some(|_, args| { - Ok((*args[0].write_lock::().unwrap() *= get_y(args)).into()) + let y = get_y(args); + Ok((*args[0].write_lock::().unwrap() *= y).into()) }) } "/=" => { return Some(|_, args| { - Ok((*args[0].write_lock::().unwrap() /= get_y(args)).into()) + let y = get_y(args); + Ok((*args[0].write_lock::().unwrap() /= y).into()) }) } "%=" => { return Some(|_, args| { - Ok((*args[0].write_lock::().unwrap() %= get_y(args)).into()) + let y = get_y(args); + Ok((*args[0].write_lock::().unwrap() %= y).into()) }) } _ => return None, diff --git a/src/lib.rs b/src/lib.rs index 166b0c07..ae0dc0f9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -88,7 +88,7 @@ mod token; mod r#unsafe; mod utils; -pub type RhaiResult = Result>; +pub type RhaiResult = Result>; /// The system integer type. It is defined as [`i64`]. ///