use crate::ast::{ConditionTree, Expression};
pub trait Conjunctive<'a> {
fn and<E>(self, other: E) -> ConditionTree<'a>
where
E: Into<Expression<'a>>;
fn or<E>(self, other: E) -> ConditionTree<'a>
where
E: Into<Expression<'a>>;
fn not(self) -> ConditionTree<'a>;
}
impl<'a, T> Conjunctive<'a> for T
where
T: Into<Expression<'a>>,
{
fn and<E>(self, other: E) -> ConditionTree<'a>
where
E: Into<Expression<'a>>,
{
ConditionTree::And(vec![self.into(), other.into()])
}
fn or<E>(self, other: E) -> ConditionTree<'a>
where
E: Into<Expression<'a>>,
{
ConditionTree::Or(vec![self.into(), other.into()])
}
fn not(self) -> ConditionTree<'a> {
ConditionTree::not(self.into())
}
}