Use Display in top-level example for PanicInfo

This commit is contained in:
Lukas Markeffsky 2023-04-09 14:29:16 +02:00
parent 709a97fffe
commit d9f99c36fe

View File

@ -15,14 +15,10 @@ use crate::panic::Location;
/// use std::panic; /// use std::panic;
/// ///
/// panic::set_hook(Box::new(|panic_info| { /// panic::set_hook(Box::new(|panic_info| {
/// if let Some(s) = panic_info.payload().downcast_ref::<&str>() { /// println!("panic occurred: {panic_info}");
/// println!("panic occurred: {s:?}");
/// } else {
/// println!("panic occurred");
/// }
/// })); /// }));
/// ///
/// panic!("Normal panic"); /// panic!("critical system failure");
/// ``` /// ```
#[lang = "panic_info"] #[lang = "panic_info"]
#[stable(feature = "panic_hooks", since = "1.10.0")] #[stable(feature = "panic_hooks", since = "1.10.0")]