Back to articles
[Rust Guide] 3.3. Data Types - Compound Types

[Rust Guide] 3.3. Data Types - Compound Types

via Dev.toSomeB1oody

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 ); } Acce

Continue reading on Dev.to

Opens in a new tab

Read Full Article
2 views

Related Articles