From d90023984cd0151e7ff3a568dec546643d65d99a Mon Sep 17 00:00:00 2001 From: amv-dev Date: Sat, 11 Nov 2023 12:54:52 +0500 Subject: [PATCH] fix: compilation error in `OHLCV::clv` when `value_type_f32` feature is enabled --- .github/workflows/rust.yml | 6 ++++-- src/core/ohlcv.rs | 3 ++- src/lib.rs | 1 + 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 0ac5118..71c531c 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -16,9 +16,11 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Run clippy + run: cargo clippy --tests --verbose + - name: Run clippy with features + run: cargo clippy --tests --verbose --features="value_type_f32,period_type_u64,unsafe_performance" - name: Build run: cargo build --verbose - name: Run tests run: cargo test --verbose - - name: Run clippy - run: cargo clippy --tests --verbose diff --git a/src/core/ohlcv.rs b/src/core/ohlcv.rs index 7e7349a..dc21a57 100644 --- a/src/core/ohlcv.rs +++ b/src/core/ohlcv.rs @@ -121,7 +121,8 @@ pub trait OHLCV: 'static { if self.high() == self.low() { 0. } else { - (2.0f64.mul_add(self.close(), -self.low()) - self.high()) / (self.high() - self.low()) + let twice: ValueType = 2.; + (twice.mul_add(self.close(), -self.low()) - self.high()) / (self.high() - self.low()) } } diff --git a/src/lib.rs b/src/lib.rs index e1aa9ef..5156aa1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -38,6 +38,7 @@ limitations under the License. #![allow(clippy::upper_case_acronyms)] #![deny(clippy::nursery)] #![allow(clippy::use_self)] +#![cfg_attr(feature = "period_type_u64", allow(clippy::cast_possible_truncation))] //! Yet Another Technical Analysis library //!