From the course: Rust Programming: From Fundamentals to Advanced Concepts with AI-Assisted Development
Unlock this course with a free trial
Join today to access over 24,400 courses taught by industry experts.
Demo: Variable assignment and immutability - Rust Tutorial
From the course: Rust Programming: From Fundamentals to Advanced Concepts with AI-Assisted Development
Demo: Variable assignment and immutability
- [Instructor] Let's see how variable the assignment works in Rust and some of the problems that we may get into when we're running Rust and running the compiler. And although we're not looking specifically at a whole section for compiler errors, we'll be running these and going through compiler errors as we move along. So we have here a main function and we'll always have a main function for these short examples. And variable assignment is very straightforward. You use the let word, or keyword, and then the name of the variable, and you pass in here what you want. In this case, this is a string, and we're using the semicolon to indicate that that's the end of the statement. And then here we're defining weight 190. Now, we're letting the compiler infer what types we're using. We are not kind of like required to do that, so that's fine. And we have here, and I just saved, and we have here like a curly, red, curly underline. So something's going on. We're able to do expressions. In this…
Contents
-
-
-
-
-
-
(Locked)
Introduction to Rust38s
-
(Locked)
Demo: Create a new Rust project5m 37s
-
(Locked)
Demo: Overview of project files6m
-
(Locked)
Demo: Basic components of Rust code6m 27s
-
(Locked)
Demo: Variable assignment and immutability6m 17s
-
(Locked)
Demo: Basics of control flow4m 7s
-
(Locked)
Demo: Shadowing variables5m 52s
-
(Locked)
Summary of introduction to Rust47s
-
(Locked)
-
-
-
-
-
-
-
-
-