Fix feature builds.

This commit is contained in:
Stephen Chung 2021-03-22 12:18:13 +08:00
parent a82f0fc738
commit 22ff68cdc9
3 changed files with 8 additions and 14 deletions

View File

@ -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::<Dynamic>::into)
})
};
}

View File

@ -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::<Dynamic>::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::<Dynamic>::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::<Dynamic>::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::<Dynamic>::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<Decimal, Box<EvalAltResult>> {
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::<Dynamic>::into)
x.checked_rem(y).ok_or_else(|| {
make_err(format!(
"Modulo division by zero or overflow: {} % {}",
x, y
))
})
} else {
Ok(x % y)
}

View File

@ -283,7 +283,7 @@ mod float_functions {
}
}
#[rhai_fn(return_raw)]
pub fn parse_float(s: &str) -> Result<f64, Box<EvalAltResult>> {
pub fn parse_float(s: &str) -> Result<FLOAT, Box<EvalAltResult>> {
s.trim().parse::<FLOAT>().map_err(|err| {
EvalAltResult::ErrorArithmetic(
format!("Error parsing floating-point number '{}': {}", s, err),