diff --git a/src/extension/op_def.rs b/src/extension/op_def.rs index 7e95300ab..c204e8a22 100644 --- a/src/extension/op_def.rs +++ b/src/extension/op_def.rs @@ -6,6 +6,7 @@ use std::sync::Arc; use smol_str::SmolStr; +use super::simple_op::OpEnum; use super::{ Extension, ExtensionBuildError, ExtensionId, ExtensionRegistry, ExtensionSet, SignatureError, }; @@ -212,6 +213,18 @@ impl SignatureFunc { SignatureFunc::CustomFunc(func) => func.static_params(), } } + + /// Compute the concrete signature ([FunctionType]). + /// + /// # Panics + /// + /// Panics if is [SignatureFunc::CustomFunc] and there are not enough type + /// arguments provided to match the number of static parameters. + /// + /// # Errors + /// + /// This function will return an error if the type arguments are invalid or + /// there is some error in type computation. pub fn compute_signature( &self, def: &OpDef, @@ -437,9 +450,11 @@ impl Extension { } } + /// Add an operation implemented as an [OpEnum], which can provide the data + /// required to define an [OpDef]. pub fn add_op_enum( &mut self, - op: &(impl super::simple_op::OpEnum + OpName), + op: &(impl OpEnum + OpName), ) -> Result<&mut OpDef, ExtensionBuildError> { let def = self.add_op(op.name(), op.description(), op.def_signature())?; diff --git a/src/extension/simple_op.rs b/src/extension/simple_op.rs index 474cf2a50..df5e77323 100644 --- a/src/extension/simple_op.rs +++ b/src/extension/simple_op.rs @@ -71,6 +71,8 @@ pub trait OpEnum: OpName { Self::from_op_def(ext.def(), ext.args()).ok() } + /// Given the ID of the extension this operation is defined in, and a + /// registry containing that extension, return a [RegisteredEnum]. fn to_registered( self, extension_id: ExtensionId,