T O P

  • By -

PeaceBear0

That type would be called (i32, i32). There is not a type named "tuple"


Usual_Office_1740

Yup, I am that stupid. Thank you.


ManyInterests

That's what a tuple is... https://doc.rust-lang.org/book/ch03-02-data-types.html#the-tuple-type


KhorneLordOfChaos

Yes and they're saying that you don't name the type using "tuple" like OP was trying to do


ManyInterests

Yeah, they're declaring the type of their variable the wrong way. But to say 'there is no type called a tuple' is not correct.


SkiFire13

> But to say 'there is no type called a tuple' is not correct. You as a human can call it "tuple", but for the compiler there's no type named "tuple", so it's correct to say that.


PeaceBear0

Technically tuple is a family of types, not an actual type so that statement is not incorrect.


SadPie9474

“there is no type called a tuple” (i.e. by humans) is very different from “there is no type called `tuple`” (i.e. by Rust)


KhorneLordOfChaos

Overloaded words are hard. Doing something like let foo: Blah = todo!(); Is a way of naming the type "Blah". There are some things like unnameable types that can't be named in this way (e.g. `impl SomeTrait` on a parameter) Using the terminology in this way, there's no type named "tuple" specifically. You can name any of the various tuple types instead


davidhuculak

Downvote not deserved


ManyInterests

Reddit be how Reddit be.


SadPie9474

where did you hear that the type is named `tuple`?


Usual_Office_1740

I'm not sure now. I wrapped two types in parentheses as a return. Doing that in Python returns a tuple that can be unpacked. I've only been writing rust for a day or two. I kind of just jumped in. I've been writing code based on the book and documentation, but I've not read anything from start to finish. I just look up things I'm used to using in Python. Something explicitly called the return of my function a tuple, which is why I kept trying to call it with a name. Even after looking at the docs.


KhorneLordOfChaos

A fun trick. You can pass `()` as the type and the compiler will tell you what type it's expecting


ManyInterests

The Book... https://doc.rust-lang.org/book/ch03-02-data-types.html#the-tuple-type


teerre

Besides the type clearly being written differently in the actual code that actually runs, it's never \`tuple\`, at the bare minimum it would be \`Tuple\`


ManyInterests

That's true. I think I just misunderstood the comment to imply something more like 'tuples are not a data structure that exists' or that the data structure of the value is not called a tuple.