Skip to content

Enable returning &JsValue from exported functions #43

Open
@alexcrichton

Description

@alexcrichton

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    more-typesAdding support for more Rust types to cross the boundary

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions