Introduction to Tuples in Rust Programming

preview_player
Показать описание
If you know about arrays, then understanding a tuple isn't hard. An array limits you because it needs the same type of value for each element. But a tuple, it's different.

It allows values of different types--no limits. Can't believe it? Believe it.

You can even put a tuple inside another tuple. In Rust, starting with a tuple is simple. You use parentheses--that's what they're there for.

They tell Rust, this is going to be a tuple. Now, some languages use parentheses to define a set. But don't confuse a set with a tuple.

A set only has unique values listed and demands the same data type for all values. It also removes any repeated items. But remember, this is not the case with tuples in Rust.

Tuples in Rust can have multiple identical items or a combination of data types. It is one of the most basic types of data pairing you can use in Rust.
Рекомендации по теме