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 - Rust Tutorial
From the course: Rust Programming: From Fundamentals to Advanced Concepts with AI-Assisted Development
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
-
-
-
-
-
-
-
-
(Locked)
Introduction to function basics1m 11s
-
(Locked)
Demo: Simple unit functions1m 46s
-
(Locked)
Demo: Return values5m 50s
-
(Locked)
Demo: Using arguments3m 36s
-
(Locked)
Demo: The borrowing concept10m 9s
-
(Locked)
Demo: Using panic to stop a program4m
-
(Locked)
Demo: Basic error handling with match6m 55s
-
(Locked)
Summary of function basics1m 23s
-
(Locked)
-
-
-
-
-
-
-