# Question about 1-tuples

**URL:** <https://forum.dfinity.org/t/question-about-1-tuples/16195>\
**Category:** Developers\
**Created:** [October 27, 2022, 6:09pm UTC](https://forum.dfinity.org/t/question-about-1-tuples/16195 "2022-10-27T18:09:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![lastmjs](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/lastmjs/32/3406_2.png) [@lastmjs](https://forum.dfinity.org/u/lastmjs)\
**Post date:** [October 27, 2022, 6:09pm UTC](https://forum.dfinity.org/t/question-about-1-tuples/16195/1 "2022-10-27T18:09:12Z")

</div>

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

```auto
struct PrimitiveOneTuple(String);

```

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

```rust
#[ic_cdk_macros::query]
#[candid::candid_method(query)]
async fn primitive_one_tuple_return_type() -> PrimitiveOneTuple {
        // function body
    }
}

```

The candid generated for the above looks like this:

```auto
  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?

---

<div class="post-metadata">

**Author:** ![paulyoung](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/paulyoung/32/5251_2.png) [@paulyoung](https://forum.dfinity.org/u/paulyoung)\
**Post date:** [October 27, 2022, 8:13pm UTC](https://forum.dfinity.org/t/question-about-1-tuples/16195/2 "2022-10-27T20:13:34Z")

</div>

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

> <https://github.com/dfinity/candid/issues/356#issuecomment-1154340692>
>
> Below is a minimal example of my attempt to derive \`CandidType\` on a struct wher…e a field contains a value whose type originates in an external crate.
> 
> I assumed this would work but I get an error which says \`the trait bound Foo: CandidType is not satisfied\`. Is this expected?
> 
> \`\`\`rust
> \#\[derive(CandidType, Deserialize)\]
> pub struct MyStruct {
> pub foos: BTreeSet\<external\_crate::Foo\>,
> }
> 
> \`\`\`
> 
> The enum is defined as follows in the external crate. I've enabled the \`serde1\` feature in my \`Cargo.toml\` file.
> 
> \`\`\`rust
> const SIZE\_OF\_BAR: usize = 20;
> \`\`\`
> 
> \`\`\`rust
> \#\[derive(PartialEq, Eq, Hash, Ord, PartialOrd, Clone, Copy)\]
> \#\[cfg\_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))\]
> pub enum Foo {
> Bar(\[u8; SIZE\_OF\_BAR\]),
> }
> \`\`\`
> 
> Is the issue that \`CandidType\` can't be derived because of the \`enum\`?

---

<div class="post-metadata">

**Author:** ![lastmjs](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/lastmjs/32/3406_2.png) [@lastmjs](https://forum.dfinity.org/u/lastmjs)\
**Post date:** [October 27, 2022, 8:16pm UTC](https://forum.dfinity.org/t/question-about-1-tuples/16195/3 "2022-10-27T20:16:02Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![chenyan](https://avatars.discourse-cdn.com/v4/letter/c/35a633/32.png) [@chenyan](https://forum.dfinity.org/u/chenyan)\
**Post date:** [October 27, 2022, 11:18pm UTC](https://forum.dfinity.org/t/question-about-1-tuples/16195/4 "2022-10-27T23:18:48Z")

</div>

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`.

---

<div class="post-metadata">

**Author:** ![lastmjs](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/lastmjs/32/3406_2.png) [@lastmjs](https://forum.dfinity.org/u/lastmjs)\
**Post date:** [October 28, 2022, 2:06pm UTC](https://forum.dfinity.org/t/question-about-1-tuples/16195/5 "2022-10-28T14:06:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![lastmjs](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/lastmjs/32/3406_2.png) [@lastmjs](https://forum.dfinity.org/u/lastmjs)\
**Post date:** [October 28, 2022, 5:42pm UTC](https://forum.dfinity.org/t/question-about-1-tuples/16195/6 "2022-10-28T17:42:35Z")

</div>

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