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::wrapgives me the errorerror[E0525]: expected a closure that implements the
Fntrait, but this closure only implementsFnMutFeature
Let the closure argument to
Func::wrapderive fromFnMutinstead ofFnBenefit
This should allow embedder applications more freedom to build wasm modules that interact with the outside world in stateful ways
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
RefCellorCell.
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::wrapgives me the errorerror[E0525]: expected a closure that implements the
Fntrait, but this closure only implementsFnMutFeature
Let the closure argument to
Func::wrapderive fromFnMutinstead ofFnBenefit
This should allow embedder applications more freedom to build wasm modules that interact with the outside world in stateful ways
Last updated: Dec 13 2025 at 19:03 UTC