2024-06-06 23:53:30 +02:00
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
|
2024-06-13 11:34:57 +02:00
|
|
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Deserialize, Serialize)]
|
2024-06-06 23:53:30 +02:00
|
|
|
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
|
2024-06-05 20:41:00 +02:00
|
|
|
pub enum BinaryOperator {
|
|
|
|
Implication,
|
|
|
|
Or,
|
|
|
|
And,
|
|
|
|
}
|
2024-06-13 11:34:57 +02:00
|
|
|
|
|
|
|
impl BinaryOperator {
|
|
|
|
pub fn eval(&self, left: bool, right: bool) -> bool {
|
|
|
|
match self {
|
|
|
|
BinaryOperator::And => left && right,
|
|
|
|
BinaryOperator::Or => left || right,
|
|
|
|
BinaryOperator::Implication => !left || right,
|
|
|
|
}
|
|
|
|
}
|
2024-07-04 13:05:52 +02:00
|
|
|
|
|
|
|
pub fn is_and(&self) -> bool {
|
|
|
|
matches!(self, BinaryOperator::And)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn is_or(&self) -> bool {
|
|
|
|
matches!(self, BinaryOperator::Or)
|
|
|
|
}
|
2024-06-13 11:34:57 +02:00
|
|
|
}
|