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
use super::args::Args;
use crate::Query;
use ql2::term::TermType;
pub trait Arg {
fn into_query(self) -> Query;
}
impl Arg for Query {
fn into_query(self) -> Query {
Self::new(TermType::Branch).with_arg(self)
}
}
impl Arg for Args<(Query, Query, Query)> {
fn into_query(self) -> Query {
let Args((test, true_action, false_action)) = self;
test.into_query()
.with_arg(true_action)
.with_arg(false_action)
}
}
#[allow(array_into_iter)]
#[allow(clippy::into_iter_on_ref)]
impl<const N: usize> Arg for Args<([(Query, Query); N], Query)> {
fn into_query(self) -> Query {
let Args((arr, false_action)) = self;
let mut query = Query::new(TermType::Branch);
for (test, true_action) in arr.into_iter().cloned() {
query = query.with_arg(test).with_arg(true_action);
}
query.with_arg(false_action)
}
}