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§
Sourcefn required_parameters(&self) -> usize
fn required_parameters(&self) -> usize
返回必需参数的数量
Sourcefn optional_parameters(&self) -> usize
fn optional_parameters(&self) -> usize
返回可选参数的数量
Sourcefn check_types(&self, args: &[Rc<VariableType>]) -> FunctionTypecheck
fn check_types(&self, args: &[Rc<VariableType>]) -> FunctionTypecheck
检查参数类型是否匹配
Sourcefn param_type(&self, index: usize) -> Option<VariableType>
fn param_type(&self, index: usize) -> Option<VariableType>
获取指定位置参数的类型
Sourcefn param_type_str(&self, index: usize) -> String
fn param_type_str(&self, index: usize) -> String
获取指定位置参数类型的字符串表示
Sourcefn return_type(&self) -> VariableType
fn return_type(&self) -> VariableType
获取函数返回值类型
Sourcefn return_type_str(&self) -> String
fn return_type_str(&self) -> String
获取函数返回值类型的字符串表示