/// Adds the memory to the module's segment.
/// Returns the index of the memory in the module.
///
/// **Note:** In order for the returned index to be accurate,
/// all memory imports must be defined prior to adding any memories.
Adds the memory to the module's segment.
Returns the index of the memory in the module.

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