Avoid unwrapping in PanicInfo doc example.
Fixes https://github.com/rust-lang/rust/issues/51768.
This commit is contained in:
parent
b9f1a0762a
commit
d2fb2fb2a5
@ -30,7 +30,11 @@ use fmt;
|
|||||||
/// use std::panic;
|
/// use std::panic;
|
||||||
///
|
///
|
||||||
/// panic::set_hook(Box::new(|panic_info| {
|
/// panic::set_hook(Box::new(|panic_info| {
|
||||||
/// println!("panic occurred: {:?}", panic_info.payload().downcast_ref::<&str>().unwrap());
|
/// if let Some(s) = panic_info.payload().downcast_ref::<&str>() {
|
||||||
|
/// println!("panic occurred: {:?}", s);
|
||||||
|
/// } else {
|
||||||
|
/// println!("panic occurred");
|
||||||
|
/// }
|
||||||
/// }));
|
/// }));
|
||||||
///
|
///
|
||||||
/// panic!("Normal panic");
|
/// panic!("Normal panic");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user