From 5163fb0a33e9ef76c092a6369c45262c5785a4fd Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Wed, 15 Sep 2021 10:41:35 +0800 Subject: [PATCH] Upgrade to rust-decimal 1.16 and add sin/cos/tan. --- CHANGELOG.md | 1 + Cargo.toml | 2 +- src/packages/math_basic.rs | 9 +++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 760c5bb0..90425e73 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. * Added a number of constants to `Dynamic`. * Added a number of constants and `fromXXX` constant methods to `Dynamic`. +* Added `sin`, `cos` and `tan` for `Decimal` values. ### `Decimal` Values diff --git a/Cargo.toml b/Cargo.toml index f360c3ef..ef48ed62 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -92,7 +92,7 @@ default-features = false optional = true [dependencies.rust_decimal] -version = "1.15" +version = "1.16" default-features = false features = ["maths"] optional = true diff --git a/src/packages/math_basic.rs b/src/packages/math_basic.rs index f3c9c5ea..0f9f6a88 100644 --- a/src/packages/math_basic.rs +++ b/src/packages/math_basic.rs @@ -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)] pub fn sqrt(x: Decimal) -> Result> { x.sqrt()