#556·neon

Explicit function signatures

Author: MOZGIIICreated Jul 21, 2020Updated Oct 25, 2024

Inspired by wasm-bindgen, it would be great to have richer function signatures.

I'm thinking about something like this:

rust
fn add_1_to_argument(mut cx: FunctionContext, x: Handle<'_, JsNumber>) -> JsResult<JsNumber> {
    Ok(cx.number(x + 1.0))
}

instead of this:

rust
fn add_1_to_argument(mut cx: FunctionContext) -> JsResult<JsNumber> {
    let x = cx.argument::<JsNumber>(0)?.value();
    Ok(cx.number(x + 1.0))
}

This will, in turn, unlock further progress with https://github.com/neon-bindings/neon/issues/349