Skip to content

Commit 43bf0f1

Browse files
committed
fix: make {ModuleInstance,FuncContext}::exported_memory actually immutable
1 parent b7bc0c1 commit 43bf0f1

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

crates/tinywasm/src/imports.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ impl FuncContext<'_> {
7272
}
7373

7474
/// Get a reference to an exported memory
75-
pub fn exported_memory(&mut self, name: &str) -> Result<MemoryRef<'_>> {
75+
pub fn exported_memory(&self, name: &str) -> Result<MemoryRef<'_>> {
7676
self.module().exported_memory(self.store, name)
7777
}
7878

79-
/// Get a reference to an exported memory
79+
/// Get a mutable reference to an exported memory
8080
pub fn exported_memory_mut(&mut self, name: &str) -> Result<MemoryRefMut<'_>> {
8181
self.module().exported_memory_mut(self.store, name)
8282
}

crates/tinywasm/src/instance.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ impl ModuleInstance {
189189
}
190190

191191
/// Get an exported memory by name
192-
pub fn exported_memory<'a>(&self, store: &'a mut Store, name: &str) -> Result<MemoryRef<'a>> {
192+
pub fn exported_memory<'a>(&self, store: &'a Store, name: &str) -> Result<MemoryRef<'a>> {
193193
let export = self.export_addr(name).ok_or_else(|| Error::Other(format!("Export not found: {name}")))?;
194194
let ExternVal::Memory(mem_addr) = export else {
195195
return Err(Error::Other(format!("Export is not a memory: {name}")));
@@ -198,7 +198,7 @@ impl ModuleInstance {
198198
self.memory(store, mem_addr)
199199
}
200200

201-
/// Get an exported memory by name
201+
/// Get an exported memory by name (mutable)
202202
pub fn exported_memory_mut<'a>(&self, store: &'a mut Store, name: &str) -> Result<MemoryRefMut<'a>> {
203203
let export = self.export_addr(name).ok_or_else(|| Error::Other(format!("Export not found: {name}")))?;
204204
let ExternVal::Memory(mem_addr) = export else {

0 commit comments

Comments
 (0)