Panicking in Rust

Let's first understand what a thread panic is. You might already know that you can cause a panic by calling the unwrap() or expect() methods in an Option or Result, or even by calling directly to panic!(). There are multiple ways of panicking: the unimplemented!() macro panics, letting the user know that the feature is not implemented, the assert!() macro family will panic if the conditions are not satisfied, and indexing a slice out of bounds will also panic, but, what is a panic?

When talking about a single-threaded application, you might think that a panic is like exiting the program with an error, similar to the exit() function in C/C++. What might sound new to you is that a panic is something that happens at the thread ...

Get Rust High Performance now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.