refactor(argus-core): create explicit signal and and or methods
This commit is contained in:
parent
16cbaace20
commit
4084bb738b
3 changed files with 32 additions and 11 deletions
|
|
@ -10,11 +10,33 @@ impl core::ops::Not for &Signal<bool> {
|
|||
}
|
||||
}
|
||||
|
||||
impl Signal<bool> {
|
||||
/// 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<Self> for &Signal<bool> {
|
||||
type Output = Signal<bool>;
|
||||
|
||||
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<Self> for &Signal<bool> {
|
|||
type Output = Signal<bool>;
|
||||
|
||||
fn bitor(self, other: Self) -> Self::Output {
|
||||
apply2::<_, _, _, Linear>(self, other, |lhs, rhs| lhs || rhs)
|
||||
self.or(other)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue