File tree 1 file changed +9
-3
lines changed
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> {
77
77
/// use std::panic;
78
78
///
79
79
/// 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
+ /// }
81
85
/// }));
82
86
///
83
87
/// panic!("Normal panic");
@@ -112,8 +116,10 @@ impl<'a> PanicInfo<'a> {
112
116
///
113
117
/// panic::set_hook(Box::new(|panic_info| {
114
118
/// 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
+ /// );
117
123
/// } else {
118
124
/// println!("panic occurred but can't get location information...");
119
125
/// }
You can’t perform that action at this time.
0 commit comments