diff --git a/src/engine.rs b/src/engine.rs index dc645b3a..477e3f6e 100644 --- a/src/engine.rs +++ b/src/engine.rs @@ -1959,12 +1959,11 @@ impl Engine { - index .checked_abs() .ok_or_else(|| { - Box::new(EvalAltResult::ErrorArrayBounds(arr_len, index, idx_pos)) + EvalAltResult::ErrorArrayBounds(arr_len, index, idx_pos).into() }) .and_then(|n| { if n as usize > arr_len { - Err(EvalAltResult::ErrorArrayBounds(arr_len, index, idx_pos) - .into()) + EvalAltResult::ErrorArrayBounds(arr_len, index, idx_pos).into() } else { Ok(n as usize) } diff --git a/src/error.rs b/src/error.rs index 83ed5dd1..adc7cf15 100644 --- a/src/error.rs +++ b/src/error.rs @@ -225,10 +225,7 @@ impl> From for EvalAltResult { impl> From for Box { #[inline(always)] fn from(err: T) -> Self { - Box::new(EvalAltResult::ErrorRuntime( - err.as_ref().to_string().into(), - Position::NONE, - )) + EvalAltResult::ErrorRuntime(err.as_ref().to_string().into(), Position::NONE).into() } } diff --git a/src/error_parsing.rs b/src/error_parsing.rs index 1094028c..c963389e 100644 --- a/src/error_parsing.rs +++ b/src/error_parsing.rs @@ -299,7 +299,7 @@ impl fmt::Display for ParseError { impl From for Box { #[inline(always)] fn from(err: ParseErrorType) -> Self { - Box::new(err.into()) + err.into() } } @@ -313,7 +313,7 @@ impl From for EvalAltResult { impl From for Box { #[inline(always)] fn from(err: ParseError) -> Self { - Box::new(err.into()) + err.into() } } diff --git a/src/fn_call.rs b/src/fn_call.rs index a3e97465..61911f74 100644 --- a/src/fn_call.rs +++ b/src/fn_call.rs @@ -681,12 +681,12 @@ impl Engine { return Ok(( if num_params < 0 { - Dynamic::FALSE + false } else { let hash_script = calc_fn_hash(fn_name.as_str(), num_params as usize); self.has_script_fn(Some(mods), state, lib, hash_script) - .into() - }, + } + .into(), false, )); } @@ -1189,12 +1189,12 @@ impl Engine { .map_err(|typ| self.make_type_mismatch_err::(typ, arg_pos))?; return Ok(if num_params < 0 { - Dynamic::FALSE + false } else { let hash_script = calc_fn_hash(&fn_name, num_params as usize); self.has_script_fn(Some(mods), state, lib, hash_script) - .into() - }); + } + .into()); } // Handle is_def_var()