[Rust Guide] 3.3. Data Types - Compound Types
3.3.0. Before the Main Text Welcome to Chapter 3 of your Rust self-study. There are 6 sections in total: Variables and Mutability Data Types: Scalar Types Data Types: Compound Types (this article) ...
![[Rust Guide] 3.3. Data Types - Compound Types](https://media2.dev.to/dynamic/image/width=1200,height=627,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg9y2m0sbq7h9z7tnxt8l.png)
Source: DEV Community
3.3.0. Before the Main Text Welcome to Chapter 3 of your Rust self-study. There are 6 sections in total: Variables and Mutability Data Types: Scalar Types Data Types: Compound Types (this article) Functions and Comments Control Flow: if else Control Flow: Loops Through the mini-game in Chapter 2 (strongly recommended for beginners who haven't read it), you should already have learned basic Rust syntax. In Chapter 3, we will go deeper into general programming concepts in Rust. 3.3.1. Introduction to Compound Types Compound types group multiple values into one type Rust provides: Tuple and Array 3.3.1. Tuple Characteristics: Can hold multiple values of different types Fixed length fn main(){ let tup:(u32,f32,i64) = (6657, 0.0721, 114514); println!("{},{},{}",tup.0,tup.1,tup.2); // Output: 6657,0.0721,114514 } Destructuring: fn main(){ let tup:(u32,f32,i64) = (6657, 0.0721, 114514); let (x, y, z) = tup; println!("{},{},{}", x, y, z); } Access: println!("{},{},{}", tup.0, tup.1, tup.2); 3.