You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
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.
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 errorFeature
Let the closure argument to
Func::wrap
derive fromFnMut
instead ofFn
Benefit
This should allow embedder applications more freedom to build wasm modules that interact with the outside world in stateful ways
The text was updated successfully, but these errors were encountered: