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 25,600 courses taught by industry experts.

Demo: The match control flow in Rust

Demo: The match control flow in Rust

- [Instructor] Match control flow is an interesting way of dealing with different scenarios that you want to handle. In other programming languages, you might see this keyword as a Case. And in Rust it's actually called Match. They don't use Case. The programming language doesn't use Case. So what it is, is that it's trying to match, in this case the name variable to certain possibilities. Each line here represents a distinct possibility. And those possibilities are defined by this thing here on the left. So the way it will work is by having the actual value that it's trying to batch on the left, followed by these two characters, the equal and the greater than character. And then like a given action. Now this could be an expression as well, but in this case it will just be printing. So what will happen here is that the hello variable assigned to name, will go through this Match block here. So name will be hello. And in this case on line number nine, it's not going to match goodbye of…

Contents