about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMara Bos <m-ou.se@m-ou.se>2024-05-16 11:49:55 +0200
committerMara Bos <m-ou.se@m-ou.se>2024-06-11 15:47:00 +0200
commitce0bc8bd588f9a2a4ba149ae6a9d3490f401c376 (patch)
treefb241efdb00eb66c4eed68cfb78e08a3f1c019e8
parentf5fe82fdcab33b4137b94014f05dd2986ea396ba (diff)
downloadrust-ce0bc8bd588f9a2a4ba149ae6a9d3490f401c376.tar.gz
rust-ce0bc8bd588f9a2a4ba149ae6a9d3490f401c376.zip
Downcast panic payload to String too in example.
-rw-r--r--library/std/src/panic.rs2
1 files changed, 2 insertions, 0 deletions
diff --git a/library/std/src/panic.rs b/library/std/src/panic.rs
index 0f999f6a93e..51228cc9907 100644
--- a/library/std/src/panic.rs
+++ b/library/std/src/panic.rs
@@ -73,6 +73,8 @@ impl<'a> PanicHookInfo<'a> {
     /// panic::set_hook(Box::new(|panic_info| {
     ///     if let Some(s) = panic_info.payload().downcast_ref::<&str>() {
     ///         println!("panic occurred: {s:?}");
+    ///     } else if let Some(s) = panic_info.payload().downcast_ref::<String>() {
+    ///         println!("panic occurred: {s:?}");
     ///     } else {
     ///         println!("panic occurred");
     ///     }