From the course: Rust Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Tuples

Tuples - Rust Tutorial

From the course: Rust Essential Training

Start my 1-month free trial

Tuples

- [Instructor] Tuples are another compound data type that can be used to group a collection of related items together. However, unlike an array whose elements must all be the same data type, a tuple can hold a mix of data types. Otherwise tuples and arrays have a lot in common. The elements have a relative order although when working with tuples that order is usually not the focus like it is when working with the arrays, the elements in a tuple are stored in a fixed length, contiguous section memory. And as with arrays the compiler needs to know the data types for each of the tuple elements so it can determine exactly how much memory the program needs to store the tuple. Going back to our car analogy, if a row of parked cars is like an array because every spot holds the same type of thing, a car, we can think of a tuple like the glove box in one of those cars. It might contain a flashlight and a tire pressure…

Contents