Skip to content

Instantly share code, notes, and snippets.

@hussachai
Created April 1, 2022 04:53
Show Gist options
  • Save hussachai/27f35cf1fa7525acf48d7eab90ebbdff to your computer and use it in GitHub Desktop.
Save hussachai/27f35cf1fa7525acf48d7eab90ebbdff to your computer and use it in GitHub Desktop.
Error Handling in Rust that Every Beginner should Know Snippet 2
pub fn unwrap(self) -> T {
match self {
Ok(t) => t,
Err(e) => unwrap_failed("called `Result::unwrap()` on an `Err` value", &e),
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment