Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable returning &JsValue from exported functions #43

Open
alexcrichton opened this issue Mar 1, 2018 · 1 comment
Open

Enable returning &JsValue from exported functions #43

alexcrichton opened this issue Mar 1, 2018 · 1 comment
Labels
more-types Adding support for more Rust types to cross the boundary

Comments

@alexcrichton
Copy link
Contributor

Right now you can't write a function like:

#[wasm_bindgen]
#[no_mangle]
pub extern fn foo(a: &JsValue) -> &JsValue {
    a
}

This is because JsValue goes through all the same machinery as Foo, but I think we want to add a specific trait for "can be returned as a reference" or maybe even just AsRef<JsValue> as I think that's the only way this can work?

Enabling this would help avoid an unnecessary Clone otherwise to extract data from wasm back into JS.

@alexcrichton
Copy link
Contributor Author

Right now this is blocked by this panic and I think the trait-based solution is probably the best way to go here, IntoWasmAbi I'm pretty sure isn't sound and seems likely to cause use-after-free

@alexcrichton alexcrichton added the more-types Adding support for more Rust types to cross the boundary label Apr 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
more-types Adding support for more Rust types to cross the boundary
Projects
None yet
Development

No branches or pull requests

1 participant