mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-07 09:13:07 +03:00
Avoid unwrapping in PanicInfo doc example.
Fixes https://github.com/rust-lang/rust/issues/51768.
This commit is contained in:
@@ -30,7 +30,11 @@
|
||||
/// 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");
|
||||
|
||||
Reference in New Issue
Block a user