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:
Guillaume Gomez 2018-07-11 10:02:03 +02:00 committed by GitHub
commit c3d8236f8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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");