Deprecate From<EvalAltResult> for Result<T, Box<EvalAltResult>> because it is clearer for code to explicitly wrap errors in Err.

This commit is contained in:
Stephen Chung
2021-10-19 23:52:58 +08:00
parent 6d31bb0d19
commit 3001e90775
23 changed files with 226 additions and 193 deletions

View File

@@ -14,7 +14,7 @@ mod core_functions {
#[rhai_fn(name = "set_tag", set = "tag", return_raw)]
pub fn set_tag(value: &mut Dynamic, tag: INT) -> Result<(), Box<EvalAltResult>> {
if tag < Tag::MIN as INT {
EvalAltResult::ErrorArithmetic(
Err(EvalAltResult::ErrorArithmetic(
format!(
"{} is too small to fit into a tag (must be between {} and {})",
tag,
@@ -23,9 +23,9 @@ mod core_functions {
),
Position::NONE,
)
.into()
.into())
} else if tag > Tag::MAX as INT {
EvalAltResult::ErrorArithmetic(
Err(EvalAltResult::ErrorArithmetic(
format!(
"{} is too large to fit into a tag (must be between {} and {})",
tag,
@@ -34,7 +34,7 @@ mod core_functions {
),
Position::NONE,
)
.into()
.into())
} else {
value.set_tag(tag as Tag);
Ok(())