![[Rust Guide] 3.2. Scalar Types](/_next/image?url=https%3A%2F%2Fmedia2.dev.to%2Fdynamic%2Fimage%2Fwidth%3D1200%2Cheight%3D627%2Cfit%3Dcover%2Cgravity%3Dauto%2Cformat%3Dauto%2Fhttps%253A%252F%252Fdev-to-uploads.s3.amazonaws.com%252Fuploads%252Farticles%252F58cqx8pu9xs88qvxtn5t.png&w=1200&q=75)
[Rust Guide] 3.2. Scalar Types
3.2.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 (this article) Data Types: Compound Types 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.2.1. Characteristics of Variables in Rust Rust is a statically compiled language, meaning all variable types must be known at compile time. Based on usage, the compiler can usually infer the specific type. If multiple types are possible, explicit type annotation is required, otherwise compilation will fail. Example: let guess = "6657" .parse () .expect ( "Please enter a number" ); If you put this in an IDE, you will see: type error: type annotations needed . This is because 6657 can fit into multiple types suc
Continue reading on Dev.to
Opens in a new tab



