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)), }) }