Skip to content

Commit 249d63e

Browse files
committed
Use payload_as_str instead of two downcasts.
1 parent 15677e9 commit 249d63e

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

std/src/panic.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,7 @@ impl fmt::Display for PanicHookInfo<'_> {
202202
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
203203
formatter.write_str("panicked at ")?;
204204
self.location.fmt(formatter)?;
205-
if let Some(payload) = self.payload.downcast_ref::<&'static str>() {
206-
formatter.write_str(":\n")?;
207-
formatter.write_str(payload)?;
208-
} else if let Some(payload) = self.payload.downcast_ref::<String>() {
205+
if let Some(payload) = self.payload_as_str() {
209206
formatter.write_str(":\n")?;
210207
formatter.write_str(payload)?;
211208
}

0 commit comments

Comments
 (0)