From f34b89320fb7cfe70a71d7c7a590b98d6ff721b3 Mon Sep 17 00:00:00 2001 From: m5l14i11 Date: Fri, 30 Jun 2023 13:10:20 +0400 Subject: [PATCH] keep refs --- ta_lib/momentum/src/macd.rs | 4 ++-- ta_lib/momentum/src/rsi.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ta_lib/momentum/src/macd.rs b/ta_lib/momentum/src/macd.rs index 3c38fe3f..b0020268 100644 --- a/ta_lib/momentum/src/macd.rs +++ b/ta_lib/momentum/src/macd.rs @@ -12,7 +12,7 @@ pub fn macd( let macd_line = ema_fast .iter() .zip(&ema_slow) - .map(|(fast, slow)| match (fast, slow) { + .map(|(&fast, &slow)| match (fast, slow) { (Some(fast), Some(slow)) => Some(fast - slow), _ => None, }) @@ -29,7 +29,7 @@ pub fn macd( let histogram = macd_line .iter() .zip(&signal_line) - .map(|(macd, signal)| match (macd, signal) { + .map(|(&macd, &signal)| match (macd, signal) { (Some(macd), Some(signal)) => Some(macd - signal), _ => None, }) diff --git a/ta_lib/momentum/src/rsi.rs b/ta_lib/momentum/src/rsi.rs index 61a72524..a3fb1694 100644 --- a/ta_lib/momentum/src/rsi.rs +++ b/ta_lib/momentum/src/rsi.rs @@ -22,7 +22,7 @@ pub fn rsi(data: &[f64], period: usize) -> Vec> { let rsi = avg_gain .iter() - .zip(avg_loss.iter()) + .zip(&avg_loss) .map(|(&gain, &loss)| match (gain, loss) { (Some(gain), Some(loss)) if gain + loss > 0.0 => { let rs = gain / (loss + std::f64::EPSILON);