#[macro_export]
macro_rules! function {
($(#[$outer:meta])* $ty:ident ( $($arg:ident),* ) $body:block) => {
#[allow(non_camel_case_types)]
$(#[$outer])*
pub(crate) struct $ty;
impl $crate::Function for $ty {
fn name(&self) -> &str {
stringify!($ty)
}
fn arity(&self) -> usize {
function!(!count $($arg)*)
}
fn call<'a>(&self, args: &[::std::borrow::Cow<'a, $crate::FilterValue<'a>>]) -> ::std::borrow::Cow<'a, $crate::FilterValue<'a>> {
#[allow(unused_variables, unused_mut)]
let mut iter = args.iter();
$(let $arg = iter.next().unwrap();)*
$body
}
}
};
(!count $x:tt $($xs:tt)*) => {
1usize $(+ function!(!count $xs))*
};
(!count) => {
0usize
};
}