Use into().

This commit is contained in:
Stephen Chung 2021-10-11 15:49:51 +08:00
parent 4908b58473
commit 90b6b15f15
4 changed files with 11 additions and 15 deletions

View File

@ -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)
}

View File

@ -225,10 +225,7 @@ impl<T: AsRef<str>> From<T> for EvalAltResult {
impl<T: AsRef<str>> From<T> for Box<EvalAltResult> {
#[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()
}
}

View File

@ -299,7 +299,7 @@ impl fmt::Display for ParseError {
impl From<ParseErrorType> for Box<EvalAltResult> {
#[inline(always)]
fn from(err: ParseErrorType) -> Self {
Box::new(err.into())
err.into()
}
}
@ -313,7 +313,7 @@ impl From<ParseErrorType> for EvalAltResult {
impl From<ParseError> for Box<EvalAltResult> {
#[inline(always)]
fn from(err: ParseError) -> Self {
Box::new(err.into())
err.into()
}
}

View File

@ -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::<crate::INT>(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()