RsRust · Lesson 5 of 8
Error Handling
Rust doesn't have exceptions. Instead it has Result<T, E> and Option<T>, which force you to handle errors. This sounds annoying until you use a language that doesn't do this.
◆ Note
The ? operator is your best friend. It unwraps Ok/Some values and returns early with Err/None if the value is absent. It replaces dozens of match statements and makes error-handling code clean.
The ? operator is your best friend. It unwraps Ok/Some values and returns early with Err/None if the value is absent. It replaces dozens of match statements and makes error-handling code clean.