macro_rules! func {
($code:expr) => {
|args: Vec<crate::eval::EvalResult>| {
crate::eval_str($code, {
let mut ctx = crate::stdlib::STDLIB.clone();
for (k, v) in args
.iter()
.cloned()
.enumerate()
.map(|(k, v)| (format!("${k}"), v))
{
ctx.vars.insert(k, v.into());
}
ctx.vars.insert(
"$arguments".to_string(),
crate::eval::EvalResult::Array(args).into(),
);
ctx
})
.unwrap()
}
};
}
pub(crate) use func;