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: Basic error handling with match

Demo: Basic error handling with match

- [Instructor] If you're seeing panic. If you've dealt with panicking before in Rust programs, as a way of dealing with errors, well, there are other ways that we can deal with errors and that is using match. And we've seen a little bit of match before, but not for dealing with errors. And in this case, we are going to be using... We're going to be demonstrating how you can use this matching to say, "Hey, is this okay or are we going to get an error?" So here we're going to have, like, a file that open. Now, this can... If you've ever worked with files in any file system, you might understand that, you know, a file might not exist. A file might be in the incorrect place, or you have the wrong permissions, or not enough permissions to read it or to write to it. Or you can read it but not write to it. I mean, all kinds of different things that can happen. So in this case, we open the file and we say, "Hey, you know, like, this file that we just opened, let's just make sure that it does…

Contents