grafbase_sql_ast/ast/
conjunctive.rs1use crate::ast::{ConditionTree, Expression};
2
3pub trait Conjunctive<'a> {
5 fn and<E>(self, other: E) -> ConditionTree<'a>
7 where
8 E: Into<Expression<'a>>;
9
10 fn or<E>(self, other: E) -> ConditionTree<'a>
12 where
13 E: Into<Expression<'a>>;
14
15 fn not(self) -> ConditionTree<'a>;
17}
18
19impl<'a, T> Conjunctive<'a> for T
20where
21 T: Into<Expression<'a>>,
22{
23 fn and<E>(self, other: E) -> ConditionTree<'a>
24 where
25 E: Into<Expression<'a>>,
26 {
27 ConditionTree::And(vec![self.into(), other.into()])
28 }
29
30 fn or<E>(self, other: E) -> ConditionTree<'a>
31 where
32 E: Into<Expression<'a>>,
33 {
34 ConditionTree::Or(vec![self.into(), other.into()])
35 }
36
37 fn not(self) -> ConditionTree<'a> {
38 ConditionTree::not(self.into())
39 }
40}