gtmpl-rust
gtmpl-rust copied to clipboard
Allow closures to be added as functions.
Happy to write the PR for this, but is there any chance you'd consider allowing adding Closures to the function map.
I used this all the time in Go, and now in rust I'd really like to.
Maybe another function
pub enum MapFunc{
Closure(Box<Fn(&[Value])->Result<Value,String>),
Static(fn(&[Value]->Result<Value,String>),
}
//Then add the function
impl Template {
add_closure(f:Box<Fn(&[Value])->Result<Value,String>{
///...
}
}