Skip to content

Support for Tuples and Tuple Struct #1372

@CMCDragonkai

Description

@CMCDragonkai

Is there a reason why we cannot export a tuple struct or tuple to the JS side?

#[napi]
pub fn plus_100(input: u32) -> (u32, u32) {
  (input, input)
}

#[napi]
pub struct X(u32, u32);

#[napi]
pub fn plus_200(input: u32) -> X {
  X(input, input)
}

In the first case, the macro complains:

the trait bound `(u32, u32): NapiRaw` is not satisfied
required because of the requirements on the impl of `napi::bindgen_prelude::ToNapiValue` for `(u32, u32)`

In the second case, the macros don't complain, but on the JS side, I get a X object with no properties...

On the JS side I would be expecting a heterogeneous array of some sort.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions