use error::{self, Error}; use value::Value; pub mod builtin; pub struct Function { argument_amount: Option, function: Box Result>, } impl Function { pub fn new( argument_amount: Option, function: Box Result>, ) -> Self { Self { argument_amount, function, } } pub fn call(&self, arguments: &[Value]) -> Result { if let Some(argument_amount) = self.argument_amount { error::expect_function_argument_amount(arguments.len(), argument_amount)?; } (self.function)(arguments) } }