3 ms·
Rust's error handling is in my opinion perfect. An operation that can fail will return a Result<T, E> type, it will either be Ok(T), or Err(E). You can pattern
by rhinoceraptor 3y ago
Rust's error handling is in my opinion perfect. An operation that can fail will return a Result<T, E> type, it will either be Ok(T), or Err(E). You can pattern match a Result, and decide what to do with it.
Or, more likely, you just want to pass that error back up to your calling function to decide what to do with it, so you just put a ? on the end of your function call like this:
let result = potentially_failing_function()?;