Fix feature builds.
This commit is contained in:
parent
a82f0fc738
commit
22ff68cdc9
@ -130,7 +130,7 @@ pub fn get_builtin_binary_op_fn(
|
|||||||
return Some(|_, args| {
|
return Some(|_, args| {
|
||||||
let x = <$base>::from(args[0].$xx().unwrap());
|
let x = <$base>::from(args[0].$xx().unwrap());
|
||||||
let y = <$base>::from(args[1].$yy().unwrap());
|
let y = <$base>::from(args[1].$yy().unwrap());
|
||||||
$func(x, y)
|
$func(x, y).map(Into::<Dynamic>::into)
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -445,7 +445,6 @@ pub mod decimal_functions {
|
|||||||
if cfg!(not(feature = "unchecked")) {
|
if cfg!(not(feature = "unchecked")) {
|
||||||
x.checked_add(y)
|
x.checked_add(y)
|
||||||
.ok_or_else(|| make_err(format!("Addition overflow: {} + {}", x, y)))
|
.ok_or_else(|| make_err(format!("Addition overflow: {} + {}", x, y)))
|
||||||
.map(Into::<Dynamic>::into)
|
|
||||||
} else {
|
} else {
|
||||||
Ok(x + y)
|
Ok(x + y)
|
||||||
}
|
}
|
||||||
@ -455,7 +454,6 @@ pub mod decimal_functions {
|
|||||||
if cfg!(not(feature = "unchecked")) {
|
if cfg!(not(feature = "unchecked")) {
|
||||||
x.checked_sub(y)
|
x.checked_sub(y)
|
||||||
.ok_or_else(|| make_err(format!("Subtraction overflow: {} - {}", x, y)))
|
.ok_or_else(|| make_err(format!("Subtraction overflow: {} - {}", x, y)))
|
||||||
.map(Into::<Dynamic>::into)
|
|
||||||
} else {
|
} else {
|
||||||
Ok(x - y)
|
Ok(x - y)
|
||||||
}
|
}
|
||||||
@ -465,7 +463,6 @@ pub mod decimal_functions {
|
|||||||
if cfg!(not(feature = "unchecked")) {
|
if cfg!(not(feature = "unchecked")) {
|
||||||
x.checked_mul(y)
|
x.checked_mul(y)
|
||||||
.ok_or_else(|| make_err(format!("Multiplication overflow: {} * {}", x, y)))
|
.ok_or_else(|| make_err(format!("Multiplication overflow: {} * {}", x, y)))
|
||||||
.map(Into::<Dynamic>::into)
|
|
||||||
} else {
|
} else {
|
||||||
Ok(x * y)
|
Ok(x * y)
|
||||||
}
|
}
|
||||||
@ -479,7 +476,6 @@ pub mod decimal_functions {
|
|||||||
} else {
|
} else {
|
||||||
x.checked_div(y)
|
x.checked_div(y)
|
||||||
.ok_or_else(|| make_err(format!("Division overflow: {} / {}", x, y)))
|
.ok_or_else(|| make_err(format!("Division overflow: {} / {}", x, y)))
|
||||||
.map(Into::<Dynamic>::into)
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Ok(x / y)
|
Ok(x / y)
|
||||||
@ -488,14 +484,12 @@ pub mod decimal_functions {
|
|||||||
#[rhai_fn(skip, return_raw)]
|
#[rhai_fn(skip, return_raw)]
|
||||||
pub fn modulo(x: Decimal, y: Decimal) -> Result<Decimal, Box<EvalAltResult>> {
|
pub fn modulo(x: Decimal, y: Decimal) -> Result<Decimal, Box<EvalAltResult>> {
|
||||||
if cfg!(not(feature = "unchecked")) {
|
if cfg!(not(feature = "unchecked")) {
|
||||||
x.checked_rem(y)
|
x.checked_rem(y).ok_or_else(|| {
|
||||||
.ok_or_else(|| {
|
make_err(format!(
|
||||||
make_err(format!(
|
"Modulo division by zero or overflow: {} % {}",
|
||||||
"Modulo division by zero or overflow: {} % {}",
|
x, y
|
||||||
x, y
|
))
|
||||||
))
|
})
|
||||||
})
|
|
||||||
.map(Into::<Dynamic>::into)
|
|
||||||
} else {
|
} else {
|
||||||
Ok(x % y)
|
Ok(x % y)
|
||||||
}
|
}
|
||||||
|
@ -283,7 +283,7 @@ mod float_functions {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[rhai_fn(return_raw)]
|
#[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| {
|
s.trim().parse::<FLOAT>().map_err(|err| {
|
||||||
EvalAltResult::ErrorArithmetic(
|
EvalAltResult::ErrorArithmetic(
|
||||||
format!("Error parsing floating-point number '{}': {}", s, err),
|
format!("Error parsing floating-point number '{}': {}", s, err),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user