We want to be able to reason about if a signal is empty, constant, or sampled at compile time without using any trait objects. Moreover, the core Argus library shouldn't care about how it deals with interfacing with other languages like Python. Thus, we remove the need for having an `AnySignal` type and what not.
26 lines
603 B
Rust
26 lines
603 B
Rust
use crate::signals::utils::{apply1, apply2};
|
|
use crate::signals::Signal;
|
|
|
|
impl core::ops::Not for &Signal<bool> {
|
|
type Output = Signal<bool>;
|
|
|
|
fn not(self) -> Self::Output {
|
|
apply1(self, |v| !v)
|
|
}
|
|
}
|
|
|
|
impl core::ops::BitAnd<Self> for &Signal<bool> {
|
|
type Output = Signal<bool>;
|
|
|
|
fn bitand(self, other: Self) -> Self::Output {
|
|
apply2(self, other, |lhs, rhs| lhs && rhs)
|
|
}
|
|
}
|
|
|
|
impl core::ops::BitOr<Self> for &Signal<bool> {
|
|
type Output = Signal<bool>;
|
|
|
|
fn bitor(self, other: Self) -> Self::Output {
|
|
apply2(self, other, |lhs, rhs| lhs || rhs)
|
|
}
|
|
}
|