1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
use crate::process::traversal::TraversalBuilder;
use crate::structure::GValue;
use crate::structure::IntoPredicate;

pub struct WhereStep {
    params: Vec<GValue>,
}

impl WhereStep {
    fn new(params: Vec<GValue>) -> Self {
        WhereStep { params }
    }
}

impl WhereStep {
    pub fn take_params(self) -> Vec<GValue> {
        self.params
    }
}

pub trait IntoWhereStep {
    fn into_step(self) -> WhereStep;
}

impl IntoWhereStep for TraversalBuilder {
    fn into_step(self) -> WhereStep {
        WhereStep::new(vec![self.bytecode.into()])
    }
}

impl<A, B> IntoWhereStep for (A, B)
where
    A: Into<String>,
    B: IntoPredicate,
{
    fn into_step(self) -> WhereStep {
        WhereStep::new(vec![self.0.into().into(), self.1.into_predicate().into()])
    }
}

impl<A> IntoWhereStep for A
where
    A: IntoPredicate,
{
    fn into_step(self) -> WhereStep {
        WhereStep::new(vec![self.into_predicate().into()])
    }
}