Skip to main content

Callable

Trait Callable 

Source
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§

Source

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.

Source

fn arity(&self) -> usize

Returns the arity of the object.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§