Struct xxcalc::evaluator::Function [] [src]

pub struct Function { /* fields omitted */ }

Definition of function with its arity.

A function is used to implement operators and other functions in the evaluator. Each function consist of FunctionHandle which process arguments into a single Polynomial value.

A function handle is guaranteed to receive a defined number of arguments, as this is checked during the evaluation (there is no need checking arity of arguments in the handler).

Methods

impl Function
[src]

Creates a new function with given arity and handler.

Handler can be a pointer to a closure or a function. A function handler is guaranteed to receive required number of arguments when called.

Examples

let f_a = Function::new(2, Box::new(functions::addition));
let f_b = Function::new(0, Box::new(|args| {
  return Ok(Polynomial::constant(42.0));
}));Run

Trait Implementations

impl Debug for Function
[src]

Debug formatter for Function

Formats the value using the given formatter.