Skip to content

Cannot use JS strings without copying them into wasm memory #287

Closed
@fitzgen

Description

@fitzgen

This doesn't work, but it should:

#[wasm_bindgen]
extern {
    #[wasm_bindgen(js_name = String)]
    pub extern type JsString;

    pub fn slice(this: &JsString, start: u32, end: u32) -> JsString;
}

This is blocking all the String related bindings in #275.

I haven't dug in very far, but I think the issue is that strings are special cased by wasm-bindgen to always copy in/out of wasm memory, and so we can't reference them as an opaque extern type.

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