From 749ebee2d588b9b5930d539995ff2473afc5cc4a Mon Sep 17 00:00:00 2001 From: bbb651 🇮🇱 <53972231+bbb651@users.noreply.github.com> Date: Thu, 17 Jul 2025 22:44:05 +0300 Subject: fix: make `{ModuleInstance,FuncContext}::exported_memory` actually immutable (#41) --- crates/tinywasm/src/imports.rs | 4 ++-- crates/tinywasm/src/instance.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'crates') diff --git a/crates/tinywasm/src/imports.rs b/crates/tinywasm/src/imports.rs index 90f4971..563e586 100644 --- a/crates/tinywasm/src/imports.rs +++ b/crates/tinywasm/src/imports.rs @@ -72,11 +72,11 @@ impl FuncContext<'_> { } /// Get a reference to an exported memory - pub fn exported_memory(&mut self, name: &str) -> Result> { + pub fn exported_memory(&self, name: &str) -> Result> { self.module().exported_memory(self.store, name) } - /// Get a reference to an exported memory + /// Get a mutable reference to an exported memory pub fn exported_memory_mut(&mut self, name: &str) -> Result> { self.module().exported_memory_mut(self.store, name) } diff --git a/crates/tinywasm/src/instance.rs b/crates/tinywasm/src/instance.rs index 75c12d6..aaa3407 100644 --- a/crates/tinywasm/src/instance.rs +++ b/crates/tinywasm/src/instance.rs @@ -189,7 +189,7 @@ impl ModuleInstance { } /// Get an exported memory by name - pub fn exported_memory<'a>(&self, store: &'a mut Store, name: &str) -> Result> { + pub fn exported_memory<'a>(&self, store: &'a Store, name: &str) -> Result> { let export = self.export_addr(name).ok_or_else(|| Error::Other(format!("Export not found: {name}")))?; let ExternVal::Memory(mem_addr) = export else { return Err(Error::Other(format!("Export is not a memory: {name}"))); @@ -198,7 +198,7 @@ impl ModuleInstance { self.memory(store, mem_addr) } - /// Get an exported memory by name + /// Get an exported memory by name (mutable) pub fn exported_memory_mut<'a>(&self, store: &'a mut Store, name: &str) -> Result> { let export = self.export_addr(name).ok_or_else(|| Error::Other(format!("Export not found: {name}")))?; let ExternVal::Memory(mem_addr) = export else { -- cgit v1.3.1