diff --git a/argus-core/src/signals.rs b/argus-core/src/signals.rs index b79ca64..c4e6a28 100644 --- a/argus-core/src/signals.rs +++ b/argus-core/src/signals.rs @@ -12,16 +12,16 @@ mod utils; use std::ops::{Bound, RangeBounds}; use std::time::Duration; -pub use bool_ops::*; -pub use cast::*; -pub use cmp_ops::*; use itertools::Itertools; -pub use num_ops::*; use num_traits::Num; -pub use shift_ops::*; -pub use traits::*; -use utils::intersect_bounds; +pub use self::bool_ops::*; +pub use self::cast::*; +pub use self::cmp_ops::*; +pub use self::num_ops::*; +pub use self::shift_ops::*; +pub use self::traits::*; +use self::utils::intersect_bounds; use crate::{ArgusResult, Error}; /// A single sample of a signal. diff --git a/argus-core/src/signals/bool_ops.rs b/argus-core/src/signals/bool_ops.rs index b4eb231..46fbccc 100644 --- a/argus-core/src/signals/bool_ops.rs +++ b/argus-core/src/signals/bool_ops.rs @@ -10,11 +10,33 @@ impl core::ops::Not for &Signal { } } +impl Signal { + /// Apply logical conjunction for each sample across the two signals. + /// + /// Here, the conjunction is taken at all signal points where either of the signals + /// are sampled, and where they intersect (using interpolation). + /// + /// See [`Signal::sync_with_intersection`]. + pub fn and(&self, other: &Self) -> Self { + apply2::<_, _, _, Linear>(self, other, |lhs, rhs| lhs && rhs) + } + + /// Apply logical disjunction for each sample across the two signals. + /// + /// Here, the disjunction is taken at all signal points where either of the signals + /// are sampled, and where they intersect (using interpolation). + /// + /// See [`Signal::sync_with_intersection`]. + pub fn or(&self, other: &Self) -> Self { + apply2::<_, _, _, Linear>(self, other, |lhs, rhs| lhs || rhs) + } +} + impl core::ops::BitAnd for &Signal { type Output = Signal; fn bitand(self, other: Self) -> Self::Output { - apply2::<_, _, _, Linear>(self, other, |lhs, rhs| lhs && rhs) + self.and(other) } } @@ -22,6 +44,6 @@ impl core::ops::BitOr for &Signal { type Output = Signal; fn bitor(self, other: Self) -> Self::Output { - apply2::<_, _, _, Linear>(self, other, |lhs, rhs| lhs || rhs) + self.or(other) } } diff --git a/argus-core/src/signals/shift_ops.rs b/argus-core/src/signals/shift_ops.rs index 8282bee..f2d864f 100644 --- a/argus-core/src/signals/shift_ops.rs +++ b/argus-core/src/signals/shift_ops.rs @@ -24,8 +24,7 @@ where // Find the first index that satisfies `t >= delta` while also checking // if we need to interpolate - let Some((idx, first_t)) = time_points.iter().find_position(|&t| t >= &delta) - else { + let Some((idx, first_t)) = time_points.iter().find_position(|&t| t >= &delta) else { // Return an empty signal (we exhauseted all samples). return Signal::Empty; };