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,900 courses taught by industry experts.
Demo: Basics of control flow - Rust Tutorial
From the course: Rust Programming: From Fundamentals to Advanced Concepts with AI-Assisted Development
Demo: Basics of control flow
- [Instructor] Now let's work with the basics of control flow in Rust. As always, we'll have a main function and we'll do some simple execution here with a VS code. You'll see that Rust analyzer allows me to have these run or debug control here. Now what do we have here? Well, we've assigned the variable and then we are doing simple if or else, you can see here that we have the curly brackets, we've mentioned curly brackets before. Those denote the scope. So this means that all of that will be scoped to the main function, but what's the deal with this curly bracket here and this other curly bracket? Well, those are also required when we are doing this if or else, that those also can be in line, like it can be in the same line, but we are formatting according to just regular formatting with Rust code. Alright, so let's take a quick look at what we have here and let's just run it. Now, if you've been paying attention, this will not compile and we won't be able to run. Do you catch that?…
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)
-
-
-
-
-
-
-
-
-