shlogg · Early preview
Jeff Mitchell @sentinel1909

Rust Compound Data Types: Tuples And Arrays Explained

Rust's compound data types: Tuples & Arrays explained. Learn how to create, access & use them in your code.

Selecting a data structure model is a key step in software development. Previously, I showed the very basic single data types in Rust. This article covers compound data types. Compound types can incorporate multiple building blocks in one overall type.

  
  
  Tuples

A tuple can contain multiple values, each with their own type, into one single entity. Tuples have a fixed length, they cannot grow or shrink later on. Tuples are stored on the stack in memory. Care is needed up front with creation because a tuples size can’t be modified later. You can modify the values inside the tuple, but new...