Sometimes, there is no way for an execution thread to continue. This may be due to things such as invalid configuration files, unresponsive peers or servers, or OS-related errors. Rust has many ways to panic, explicitly or implicitly. The most ubiquitous one is probably unwrap() for multiple Option types and related types, which panic on error or None. Yet, for more complex programs, it is essential to take control of the panicking (for example, by avoiding multiple unwrap() calls and libraries that use it) and the panic! macro supports that.
Panicking responsibly
How to do it...
Let's examine how we can take control of multiple panic! instances:
- Create a new project with cargo new panicking-responsibly --lib and open...