mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-20 08:16:31 +00:00
Add support for mutable stack closures
This commit adds support for passing `&mut FnMut(..)` to JS via imports. These closures cannot be invoked recursively in JS (they invalidate themselves while they're being invoked) and otherwise work the same as `&Fn(..)` closures. Closes #123
This commit is contained in:
@ -212,13 +212,14 @@ impl Descriptor {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn stack_closure(&self) -> Option<&Function> {
|
||||
let inner = match *self {
|
||||
Descriptor::Ref(ref d) => &**d,
|
||||
pub fn stack_closure(&self) -> Option<(&Function, bool)> {
|
||||
let (inner, mutable) = match *self {
|
||||
Descriptor::Ref(ref d) => (&**d, false),
|
||||
Descriptor::RefMut(ref d) => (&**d, true),
|
||||
_ => return None,
|
||||
};
|
||||
match *inner {
|
||||
Descriptor::Function(ref f) => Some(f),
|
||||
Descriptor::Function(ref f) => Some((f, mutable)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user