ISibboI/evalexpr

.set_function Does not support Fn

Closed this issue · 1 comments

error[E0308]: mismatched types
  --> src/parser.rs:41:52
   |
41 |           context.set_function(x.name, Function::new(| argument| {
   |  ____________________________________________________^
42 | |             let arguments = argument.as_tuple()?;
43 | |             let mut args: Vec<i64> = Vec::new();
44 | |             for v in arguments.iter() {
...  |
50 | |             Ok(function)
51 | |         })).unwrap();
   | |_________^ expected fn pointer, found closure
   |
   = note: expected fn pointer `for<'r> fn(&'r Value) -> Result<Value, EvalexprError>`
                 found closure `[closure@src/parser.rs:41:52: 51:10]`
note: closures can only be coerced to `fn` types if they do not capture any variables```

Hi, thank you very much for the report. I was not aware that Function cannot take a closure. Good that jakubdabek already made a pull request for this, then we should be able to fix this quickly.