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

        globals.push(global);

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

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