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
use crate::expr::Expr;
use crate::item::FuncCall;
use crate::item::FuncRef;
#[inline]
pub fn func<'a, F, A, I>(func: F, args: I) -> FuncCall<'a>
where
    F: Into<FuncRef<'a>>,
    A: Into<Expr<'a>>,
    I: IntoIterator<Item = A>,
{
    FuncCall(func.into(), args.into_iter().map(Into::into).collect())
}
macro_rules! gen_funcs {
    ($($(#[$comment:meta])* $func:ident),+) => {
        $(
            $(#[$comment])*
            #[inline]
            pub fn $func<'a, A>(arg: A) -> FuncCall<'a>
            where
                A: Into<Expr<'a>>,
            {
                func(stringify!($func), [arg.into()])
            }
        )+
    };
}
gen_funcs!(
    
    sum,
    
    count,
    
    avg,
    
    min,
    
    max
);