Skip to content

Commit

Permalink
Use payload_as_str instead of two downcasts.
Browse files Browse the repository at this point in the history
  • Loading branch information
m-ou-se committed Jun 12, 2024
1 parent 15677e9 commit 249d63e
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions std/src/panic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,7 @@ impl fmt::Display for PanicHookInfo<'_> {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_str("panicked at ")?;
self.location.fmt(formatter)?;
if let Some(payload) = self.payload.downcast_ref::<&'static str>() {
formatter.write_str(":\n")?;
formatter.write_str(payload)?;
} else if let Some(payload) = self.payload.downcast_ref::<String>() {
if let Some(payload) = self.payload_as_str() {
formatter.write_str(":\n")?;
formatter.write_str(payload)?;
}
Expand Down

0 comments on commit 249d63e

Please sign in to comment.