pub trait Callable: Debug {
// Required methods
fn call(
&self,
interpreter: &mut Interpreter<'_>,
arguments: Vec<Object>,
) -> Result<Object, RuntimeError>;
fn arity(&self) -> usize;
}Expand description
Represents a callable object in the language.
Required Methods§
Sourcefn call(
&self,
interpreter: &mut Interpreter<'_>,
arguments: Vec<Object>,
) -> Result<Object, RuntimeError>
fn call( &self, interpreter: &mut Interpreter<'_>, arguments: Vec<Object>, ) -> Result<Object, RuntimeError>
Calls the object with the given arguments and the current state of the interpreter. The interpreter is passed in as a mutable refernece so that the object can access the environment and call other functions. It returns the result of the call or an error if the call failed for some reason.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".