gtmpl-rust icon indicating copy to clipboard operation
gtmpl-rust copied to clipboard

Allow closures to be added as functions.

Open storyfeet opened this issue 4 years ago • 0 comments

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>{
        ///...
    }
}

storyfeet avatar Jul 22 '20 13:07 storyfeet