Question about 1-tuples

I have a little bit of confusion over 1-tuples. For example, in Rust I might have a 1-tuple defined like so:

struct PrimitiveOneTuple(String);

I might want to use this type of 1-tuple in a Rust function like so:

async fn primitive_one_tuple_return_type() -> PrimitiveOneTuple {
        // function body

The candid generated for the above looks like this:

  primitive_one_tuple_return_type : () -> (text) query;

The candid that is generated from this turns PrimitiveOneTuple into just text. Is this correct behavior? Is there no such thing as a 1-tuple in Candid?

I’m not sure if it doesn’t exist but it can be omitted according to @chenyan and based on my own experience.

I would prefer or hope that a 1-tuple would just be treated like a 1-tuple, but for example in Candid and the thus the JS agent, the 1-tuple is removed and just the underlying type is used.

I think the following would produce 1-tuple:

struct PrimitiveOneTuple((String,));

struct A(String) is a newtype in Rust, and by convention, A represents its inner type String.


Ah, I will look into this. Seems like it’s on our side then.

Seems to be working so far, our Candid looks good and our tests are passing. Thanks!