Upgrade to rust-decimal 1.16 and add sin/cos/tan.

This commit is contained in:
Stephen Chung 2021-09-15 10:41:35 +08:00
parent bdbfa8ef5f
commit 5163fb0a33
3 changed files with 11 additions and 1 deletions

View File

@ -29,6 +29,7 @@ Enhancements
* `Dynamic::as_string` and `Dynamic::as_immutable_string` are deprecated and replaced by `into_string` and `into_immutable_string` respectively. * `Dynamic::as_string` and `Dynamic::as_immutable_string` are deprecated and replaced by `into_string` and `into_immutable_string` respectively.
* Added a number of constants to `Dynamic`. * Added a number of constants to `Dynamic`.
* Added a number of constants and `fromXXX` constant methods to `Dynamic`. * Added a number of constants and `fromXXX` constant methods to `Dynamic`.
* Added `sin`, `cos` and `tan` for `Decimal` values.
### `Decimal` Values ### `Decimal` Values

View File

@ -92,7 +92,7 @@ default-features = false
optional = true optional = true
[dependencies.rust_decimal] [dependencies.rust_decimal]
version = "1.15" version = "1.16"
default-features = false default-features = false
features = ["maths"] features = ["maths"]
optional = true optional = true

View File

@ -325,6 +325,15 @@ mod decimal_functions {
} }
} }
pub fn sin(x: Decimal) -> Decimal {
x.sin()
}
pub fn cos(x: Decimal) -> Decimal {
x.cos()
}
pub fn tan(x: Decimal) -> Decimal {
x.tan()
}
#[rhai_fn(return_raw)] #[rhai_fn(return_raw)]
pub fn sqrt(x: Decimal) -> Result<Decimal, Box<EvalAltResult>> { pub fn sqrt(x: Decimal) -> Result<Decimal, Box<EvalAltResult>> {
x.sqrt() x.sqrt()