From 5e79b8ba0dbb7d7120aeeeb0bad4c6acb6198ed4 Mon Sep 17 00:00:00 2001 From: m5l14i11 Date: Mon, 24 Jul 2023 11:39:24 +0300 Subject: [PATCH] bool --- ta_lib/core/src/bool.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ta_lib/core/src/bool.rs b/ta_lib/core/src/bool.rs index 6b8d52ef..aa8b139f 100644 --- a/ta_lib/core/src/bool.rs +++ b/ta_lib/core/src/bool.rs @@ -66,3 +66,19 @@ impl Series { self.compare_series(rhs, |a, b| a <= b) } } + +impl Series { + pub fn and(&self, rhs: &Series) -> Series { + self.zip_with(rhs, |a, b| match (a, b) { + (Some(a_val), Some(b_val)) => Some(*a_val & *b_val), + _ => None, + }) + } + + pub fn or(&self, rhs: &Series) -> Series { + self.zip_with(rhs, |a, b| match (a, b) { + (Some(a_val), Some(b_val)) => Some(*a_val | *b_val), + _ => None, + }) + } +}