Рет қаралды 7,978
Strengthen your code one level at a time. Rust's errors can be confusing. Learn how to start with an easy path and grow as you knowledge increases. This video was produced first for patrons / timclicks
📚 Resources:
// Docs
- Error Handling in Rust - A Deep Dive www.lpalmieri.com/posts/error...
- Error Handling in Rust with Jane Lasore-Lusby rustacean-station.org/episode...
- Error Handling in Rust (old! this one is how I learned!) blog.burntsushi.net/rust-erro...
// Slides
docs.google.com/presentation/...
// Crates
- crates.io/crates/thiserror
- crates.io/crates/eyre
- crates.io/crates/anyhow
🦀 Rust resources:
- Rust Documentation: doc.rust-lang.org/book/
- Rust Playground: play.rust-lang.org/
- Rust in Action (Tim's book!) mng.bz/4MlD
- How to Learn Rust (online course!) learning.accelerant.dev/how-t...
👋 Connect with Tim:
- Twitter: / timclicks
- GitHub: github.com/timClicks
- Mastodon: mastodon.nz/@timClicks
- DEV: dev.to/timclicks/
- Patreon (extra learning materials) / timclicks
Timeline
00:00:00 Introduction
00:01:04 Personal story about learning Rust error handling
00:04:39 Combing errors
00:05:18 Using std::error:Error trait objects
00:08:20 Programmer's view of an error
00:09:40 Type system's view of an error
00:11:32 What is a Result?
00:14:12 Individual modules/crates often define their own Error types
00:16:15 Level 1: Ignore Results
00:17:10 Using unwrap()
00:18:35 Using expect()
00:19:50 Assigning to underscore (_)
00:24:18 Level 2: Return strings as errors
00:25:15 Converting errors with map_err
00:26:40 Defining a function with String as an error type
00:31:34 Level 3: use enums as errors
00:37:20 Why bother to define a custom error type
00:41:50 Level 4: use crates to help
🔔 Subscribe to the channel and click the bell icon to stay updated with the latest videos and live streams from timClicks: kzbin.info?sub...
👍 Like this video if you found it helpful, and share it with your friends who are also interested in Rust programming.