Trait FunctionDefinition

Source
pub trait FunctionDefinition: Any {
    // Required methods
    fn required_parameters(&self) -> usize;
    fn optional_parameters(&self) -> usize;
    fn check_types(&self, args: &[Rc<VariableType>]) -> FunctionTypecheck;
    fn call(&self, args: Arguments<'_>) -> Result<Variable>;
    fn param_type(&self, index: usize) -> Option<VariableType>;
    fn param_type_str(&self, index: usize) -> String;
    fn return_type(&self) -> VariableType;
    fn return_type_str(&self) -> String;
}
Expand description

函数定义特征

所有函数(内置、自定义、已废弃)都必须实现此特征

Required Methods§

Source

fn required_parameters(&self) -> usize

返回必需参数的数量

Source

fn optional_parameters(&self) -> usize

返回可选参数的数量

Source

fn check_types(&self, args: &[Rc<VariableType>]) -> FunctionTypecheck

检查参数类型是否匹配

Source

fn call(&self, args: Arguments<'_>) -> Result<Variable>

执行函数调用

Source

fn param_type(&self, index: usize) -> Option<VariableType>

获取指定位置参数的类型

Source

fn param_type_str(&self, index: usize) -> String

获取指定位置参数类型的字符串表示

Source

fn return_type(&self) -> VariableType

获取函数返回值类型

Source

fn return_type_str(&self) -> String

获取函数返回值类型的字符串表示

Implementors§