Skip to content

Can't mutate state from Funcs passed as wasm imports #1678

@J0eCool

Description

@J0eCool

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions