From 43bf0f17921a593ca257c9a33b397a720ba7f479 Mon Sep 17 00:00:00 2001 From: bbb651 Date: Sun, 29 Jun 2025 22:35:13 +0300 Subject: [PATCH] fix: make `{ModuleInstance,FuncContext}::exported_memory` actually immutable --- crates/tinywasm/src/imports.rs | 4 ++-- crates/tinywasm/src/instance.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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 {