File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -77,7 +77,11 @@ impl<'a> PanicInfo<'a> {
7777 /// use std::panic;
7878 ///
7979 /// panic::set_hook(Box::new(|panic_info| {
80- /// println!("panic occurred: {:?}", panic_info.payload().downcast_ref::<&str>().unwrap());
80+ /// if let Some(s) = panic_info.payload().downcast_ref::<&str>() {
81+ /// println!("panic occurred: {:?}", s);
82+ /// } else {
83+ /// println!("panic occurred");
84+ /// }
8185 /// }));
8286 ///
8387 /// panic!("Normal panic");
@@ -112,8 +116,10 @@ impl<'a> PanicInfo<'a> {
112116 ///
113117 /// panic::set_hook(Box::new(|panic_info| {
114118 /// if let Some(location) = panic_info.location() {
115- /// println!("panic occurred in file '{}' at line {}", location.file(),
116- /// location.line());
119+ /// println!("panic occurred in file '{}' at line {}",
120+ /// location.file(),
121+ /// location.line(),
122+ /// );
117123 /// } else {
118124 /// println!("panic occurred but can't get location information...");
119125 /// }
You can’t perform that action at this time.
0 commit comments