pub fn add_function(&mut self, function: Function) -> Result<FunctionIndex, ModelError> {
        let functions = self.module.functions.get_or_insert_with(Vec::new);
        let imports = match &self.module.imports {
            Some(imports) => imports
                .iter()
                .filter(|import| matches!(import.description(), ImportDescription::Function(_)))
                .count(),
            None => 0,
        };
        let index = u32::try_from(functions.len() + imports)?;

        functions.push(function);

        Ok(index)
    }
/// Adds the function to the module's segment.
/// Returns the index of the function in the module.
///
/// **Note:** In order for the returned index to be accurate,
/// all function imports must be defined prior to adding any functions.
Adds the function to the module's segment.
Returns the index of the function in the module.

In order for the returned index to be accurate,
all function imports must be defined prior to adding any functions.
Adds the function to the module ' s segment . Returns the index of the function in the module . In order for the returned index to be accurate all function imports must be defined prior to adding any functions .
pub fn add_function(&mut self, function: Function) -> Result<FunctionIndex, ModelError> {
        let functions = self.module.functions.get_or_insert_with(Vec::new);
        let imports = match &self.module.imports {
            Some(imports) => imports
                .iter()
                .filter(|import| matches!(import.description(), ImportDescription::Function(_)))
                .count(),
            None => 0,
        };
        let index = u32::try_from(functions.len() + imports)?;
        functions.push(function);
        Ok(index)
    }
pub fn add_function ( & mut self , function : Function ) -> Result < FunctionIndex , ModelError > { let functions = self . module . functions . get_or_insert_with ( Vec :: new ) ; let imports = match & self . module . imports { Some ( imports ) => imports . iter ( ) . filter ( | import | matches ! ( import description ( ) ImportDescription Function ( ) ) ) . count ( ) , None => 0 , } ; let index = u32 :: try_from ( functions . len ( ) + imports ) ? ; functions . push ( function ) ; Ok ( index ) }
Adds the function to the module's segment.
Adds the function to the module ' s segment .
&mut self
function
Function
&mut self
function
Function