Skip to content

Support exporting Rust functions as variadic JS functions #694

Closed
@richard-uk1

Description

@richard-uk1

Support the following example

#[wasm_bindgen(apply_ending_slice_bikeshedded)]
pub fn add(first: u32, second: u32, rest: &[u32]) -> u32 {
    rest.iter().sum() + first + second
}

callable from javascript as

import { add } from './wasm';

console.log(add(1, 2, 3, 4, 5)); // prints 15

You could implement the transformation in javascript as

function add(first, second, ..rest) {
    return add_from_rust(first, second, rest);
}

This is a prerequisite for implementing #503 the reverse of #503.

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