---
title: "How to Panic in Rust"
categories: rust
+forum: https://internals.rust-lang.org/t/how-to-panic-in-rust/11368
---
-What exactly happens when you write `panic!()`?
+What exactly happens when you `panic!()`?
I recently spent a lot of time looking at the parts of the standard library concerned with this, and it turns out the answer is quite complicated!
I have not been able to find docs explaining the high-level picture of panicking in Rust, so this feels worth writing down.
I wonder if there is any case where *both* fields will be useful -- and if not, couldn't we encode that by making them two variants of an `enum`?
There are probably good reasons against that proposal and for the current design; it would be great to get them documented somewhere. :)
-There is a lot more to say, but at this point, I invite you to follow the links to the source code that I included above and read the local comments.
-With the high-level structure in mind, those comments should be able to fill out any missing details.
-If people think this information would be worth putting somewhere more permanently, I'd be happy to work this blog post into some form of docs -- I am not sure what would be a good place for those, though.
+There is a lot more to say, but at this point, I invite you to follow the links to the source code that I included above.
+With the high-level structure in mind, you should be able to follow that code.
+If people think this overview would be worth putting somewhere more permanently, I'd be happy to work this blog post into some form of docs -- I am not sure what would be a good place for those, though.
And if you find any mistakes in what I wrote, please let me know!