lsor_core/
cond.rs

1use crate::driver::{Driver, PushPrql};
2
3pub fn and<LHS, RHS>(lhs: LHS, rhs: RHS) -> And<LHS, RHS> {
4    And { lhs, rhs }
5}
6
7pub fn eq<LHS, RHS>(lhs: LHS, rhs: RHS) -> Eq<LHS, RHS> {
8    Eq { lhs, rhs }
9}
10
11pub fn gt<LHS, RHS>(lhs: LHS, rhs: RHS) -> Gt<LHS, RHS> {
12    Gt { lhs, rhs }
13}
14
15pub fn lt<LHS, RHS>(lhs: LHS, rhs: RHS) -> Lt<LHS, RHS> {
16    Lt { lhs, rhs }
17}
18
19pub struct And<LHS, RHS> {
20    pub lhs: LHS,
21    pub rhs: RHS,
22}
23
24impl<LHS, RHS> PushPrql for And<LHS, RHS>
25where
26    LHS: PushPrql,
27    RHS: PushPrql,
28{
29    fn push_to_driver(&self, driver: &mut Driver) {
30        driver.push('(');
31        self.lhs.push_to_driver(driver);
32        driver.push(") && (");
33        self.rhs.push_to_driver(driver);
34        driver.push(')');
35    }
36}
37
38pub struct Eq<LHS, RHS> {
39    pub lhs: LHS,
40    pub rhs: RHS,
41}
42
43impl<LHS, RHS> PushPrql for Eq<LHS, RHS>
44where
45    LHS: PushPrql,
46    RHS: PushPrql,
47{
48    fn push_to_driver(&self, driver: &mut Driver) {
49        driver.push('(');
50        self.lhs.push_to_driver(driver);
51        driver.push(") == (");
52        self.rhs.push_to_driver(driver);
53        driver.push(')');
54    }
55}
56
57pub struct Gt<LHS, RHS> {
58    pub lhs: LHS,
59    pub rhs: RHS,
60}
61
62impl<LHS, RHS> PushPrql for Gt<LHS, RHS>
63where
64    LHS: PushPrql,
65    RHS: PushPrql,
66{
67    fn push_to_driver(&self, driver: &mut Driver) {
68        driver.push('(');
69        self.lhs.push_to_driver(driver);
70        driver.push(") > (");
71        self.rhs.push_to_driver(driver);
72        driver.push(')');
73    }
74}
75
76pub struct Lt<LHS, RHS> {
77    pub lhs: LHS,
78    pub rhs: RHS,
79}
80
81impl<LHS, RHS> PushPrql for Lt<LHS, RHS>
82where
83    LHS: PushPrql,
84    RHS: PushPrql,
85{
86    fn push_to_driver(&self, driver: &mut Driver) {
87        driver.push('(');
88        self.lhs.push_to_driver(driver);
89        driver.push(") < (");
90        self.rhs.push_to_driver(driver);
91        driver.push(')');
92    }
93}