Stream: git-wasmtime

Topic: wasmtime / Issue #1678 Can't mutate state from Funcs pass...


view this post on Zulip Wasmtime GitHub notifications bot (May 11 2020 at 02:43):

J0eCool opened Issue #1678:

Trying to build a graphical application using the wasmtime Rust API, using the sdl2 crate, I run in to the issue that SDL's drawing methods take a mutable reference to the screen, and using those from a closure passed to Func::wrap gives me the error

error[E0525]: expected a closure that implements the Fn trait, but this closure only implements FnMut

Feature

Let the closure argument to Func::wrap derive from FnMut instead of Fn

Benefit

This should allow embedder applications more freedom to build wasm modules that interact with the outside world in stateful ways

view this post on Zulip Wasmtime GitHub notifications bot (May 11 2020 at 14:15):

alexcrichton commented on Issue #1678:

Thanks for the report! This is required for safety when using wasm modules, however, so it's not something that we can fix. Host functions can be called recursively if they, for example, reenter wasm and then get called again.

You can get mutation through interior mutability in Rust, however, for example through RefCell or Cell.

view this post on Zulip Wasmtime GitHub notifications bot (May 11 2020 at 14:15):

alexcrichton closed Issue #1678:

Trying to build a graphical application using the wasmtime Rust API, using the sdl2 crate, I run in to the issue that SDL's drawing methods take a mutable reference to the screen, and using those from a closure passed to Func::wrap gives me the error

error[E0525]: expected a closure that implements the Fn trait, but this closure only implements FnMut

Feature

Let the closure argument to Func::wrap derive from FnMut instead of Fn

Benefit

This should allow embedder applications more freedom to build wasm modules that interact with the outside world in stateful ways


Last updated: Nov 22 2024 at 17:03 UTC