Rollup merge of #52238 - frewsxcv:frewsxcv-unwrap, r=GuillaumeGomez
Avoid unwrapping in PanicInfo doc example. Fixes https://github.com/rust-lang/rust/issues/51768.
This commit is contained in:
commit
c3d8236f8d
@ -30,7 +30,11 @@ use fmt;
|
||||
/// use std::panic;
|
||||
///
|
||||
/// 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");
|
||||
|
Loading…
Reference in New Issue
Block a user