From 22ff68cdc920bb17d688614f594b3b47ca1a0b55 Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Mon, 22 Mar 2021 12:18:13 +0800 Subject: [PATCH] Fix feature builds. --- src/fn_builtin.rs | 2 +- src/packages/arithmetic.rs | 18 ++++++------------ src/packages/math_basic.rs | 2 +- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/fn_builtin.rs b/src/fn_builtin.rs index 828de6fb..4b79cc62 100644 --- a/src/fn_builtin.rs +++ b/src/fn_builtin.rs @@ -130,7 +130,7 @@ pub fn get_builtin_binary_op_fn( return Some(|_, args| { let x = <$base>::from(args[0].$xx().unwrap()); let y = <$base>::from(args[1].$yy().unwrap()); - $func(x, y) + $func(x, y).map(Into::::into) }) }; } diff --git a/src/packages/arithmetic.rs b/src/packages/arithmetic.rs index 1844dc66..1346a5b3 100644 --- a/src/packages/arithmetic.rs +++ b/src/packages/arithmetic.rs @@ -445,7 +445,6 @@ pub mod decimal_functions { if cfg!(not(feature = "unchecked")) { x.checked_add(y) .ok_or_else(|| make_err(format!("Addition overflow: {} + {}", x, y))) - .map(Into::::into) } else { Ok(x + y) } @@ -455,7 +454,6 @@ pub mod decimal_functions { if cfg!(not(feature = "unchecked")) { x.checked_sub(y) .ok_or_else(|| make_err(format!("Subtraction overflow: {} - {}", x, y))) - .map(Into::::into) } else { Ok(x - y) } @@ -465,7 +463,6 @@ pub mod decimal_functions { if cfg!(not(feature = "unchecked")) { x.checked_mul(y) .ok_or_else(|| make_err(format!("Multiplication overflow: {} * {}", x, y))) - .map(Into::::into) } else { Ok(x * y) } @@ -479,7 +476,6 @@ pub mod decimal_functions { } else { x.checked_div(y) .ok_or_else(|| make_err(format!("Division overflow: {} / {}", x, y))) - .map(Into::::into) } } else { Ok(x / y) @@ -488,14 +484,12 @@ pub mod decimal_functions { #[rhai_fn(skip, return_raw)] pub fn modulo(x: Decimal, y: Decimal) -> Result> { if cfg!(not(feature = "unchecked")) { - x.checked_rem(y) - .ok_or_else(|| { - make_err(format!( - "Modulo division by zero or overflow: {} % {}", - x, y - )) - }) - .map(Into::::into) + x.checked_rem(y).ok_or_else(|| { + make_err(format!( + "Modulo division by zero or overflow: {} % {}", + x, y + )) + }) } else { Ok(x % y) } diff --git a/src/packages/math_basic.rs b/src/packages/math_basic.rs index 86fef583..0047111a 100644 --- a/src/packages/math_basic.rs +++ b/src/packages/math_basic.rs @@ -283,7 +283,7 @@ mod float_functions { } } #[rhai_fn(return_raw)] - pub fn parse_float(s: &str) -> Result> { + pub fn parse_float(s: &str) -> Result> { s.trim().parse::().map_err(|err| { EvalAltResult::ErrorArithmetic( format!("Error parsing floating-point number '{}': {}", s, err),