From d22c2048b8c74b7a0519d77a46ea219e1ade393a Mon Sep 17 00:00:00 2001 From: m5l14i11 Date: Fri, 14 Jul 2023 11:14:39 +0300 Subject: [PATCH] refactor --- ta_lib/core/src/ops.rs | 2 +- ta_lib/core/src/series.rs | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/ta_lib/core/src/ops.rs b/ta_lib/core/src/ops.rs index 1692ac97..4f20b09f 100644 --- a/ta_lib/core/src/ops.rs +++ b/ta_lib/core/src/ops.rs @@ -79,7 +79,7 @@ impl Series { } pub fn neg(&self) -> Series { - self.fmap(|val| val.map(|v| if *v == 0.0 { *v } else { -*v })) + self.fmap(|val| val.map(|v| v.neg())) } } diff --git a/ta_lib/core/src/series.rs b/ta_lib/core/src/series.rs index 284e1880..60156745 100644 --- a/ta_lib/core/src/series.rs +++ b/ta_lib/core/src/series.rs @@ -106,11 +106,9 @@ impl Series { } pub fn nz(&self, replacement: Option) -> Self { - let replacement = replacement.unwrap_or(0.0); - self.fmap(|opt| match opt { Some(v) => Some(*v), - None => Some(replacement), + None => Some(replacement.unwrap_or(0.0)), }) }