Make all public API's return Box<EvalAltResult> to reduce footprint.

This commit is contained in:
Stephen Chung
2020-04-21 23:25:12 +08:00
parent 0a75479637
commit 69733688bf
63 changed files with 337 additions and 303 deletions

View File

@@ -95,10 +95,10 @@ def_package!(BasicMathPackage:"Basic mathematic functions.", lib, {
"to_int",
|x: f32| {
if x > (MAX_INT as f32) {
return Err(EvalAltResult::ErrorArithmetic(
return Err(Box::new(EvalAltResult::ErrorArithmetic(
format!("Integer overflow: to_int({})", x),
Position::none(),
));
)));
}
Ok(x.trunc() as INT)
@@ -110,10 +110,10 @@ def_package!(BasicMathPackage:"Basic mathematic functions.", lib, {
"to_int",
|x: FLOAT| {
if x > (MAX_INT as FLOAT) {
return Err(EvalAltResult::ErrorArithmetic(
return Err(Box::new(EvalAltResult::ErrorArithmetic(
format!("Integer overflow: to_int({})", x),
Position::none(),
));
)));
}
Ok(x.trunc() as INT)