Polyfiill some functions for decimal+no_float.
This commit is contained in:
parent
73c0ba4ec5
commit
e0cae4546c
@ -1,6 +1,15 @@
|
||||
Rhai Release Notes
|
||||
==================
|
||||
|
||||
Version 1.1.0
|
||||
=============
|
||||
|
||||
Enhancements
|
||||
------------
|
||||
|
||||
* `parse_float()`, `PI()` and `E()` now defer to `Decimal` under `no_float` if `decimal` is turned on.
|
||||
|
||||
|
||||
Version 1.0.2
|
||||
=============
|
||||
|
||||
|
@ -309,6 +309,22 @@ mod decimal_functions {
|
||||
Decimal, MathematicalOps,
|
||||
};
|
||||
|
||||
#[cfg(feature = "no_float")]
|
||||
pub mod float_polyfills {
|
||||
#[rhai_fn(name = "PI")]
|
||||
pub fn pi() -> Decimal {
|
||||
Decimal::PI
|
||||
}
|
||||
#[rhai_fn(name = "E")]
|
||||
pub fn e() -> Decimal {
|
||||
Decimal::E
|
||||
}
|
||||
#[rhai_fn(return_raw)]
|
||||
pub fn parse_float(s: &str) -> Result<Decimal, Box<EvalAltResult>> {
|
||||
super::parse_decimal(s)
|
||||
}
|
||||
}
|
||||
|
||||
#[rhai_fn(return_raw)]
|
||||
pub fn sqrt(x: Decimal) -> Result<Decimal, Box<EvalAltResult>> {
|
||||
x.sqrt()
|
||||
|
Loading…
Reference in New Issue
Block a user