pub fn format_panic(panic_info: &PanicInfo) -> String {
    let mut expl = String::new();

    #[cfg(feature = "nightly")]
        let message = panic_info.message().map(|m| format!("{}", m));

    #[cfg(not(feature = "nightly"))]
        let message = match (
        panic_info.payload().downcast_ref::<&str>(),
        panic_info.payload().downcast_ref::<String>(),
    ) {
        (Some(s), _) => Some(s.to_string()),
        (_, Some(s)) => Some(s.to_string()),
        (None, None) => None,
    };

    let cause = match message {
        Some(m) => m,
        None => "Unknown".into(),
    };

    match panic_info.location() {
        Some(location) => expl.push_str(&format!(
            "Panic occurred in file '{}' at line {}\n",
            location.file(),
            location.line()
        )),
        None => expl.push_str("Panic location unknown.\n"),
    }

    format!("{}\n   {}\n{}", expl, cause, format_backtrace())
}
/// Format the panic message for printing to log
Format the panic message for printing to log
Format the panic message for printing to log
pub fn format_panic(panic_info: &PanicInfo) -> String {
    let mut expl = String::new();
    #[cfg(feature = "nightly")]
        let message = panic_info.message().map(|m| format!("{}", m));
    #[cfg(not(feature = "nightly"))]
        let message = match (
        panic_info.payload().downcast_ref::<&str>(),
        panic_info.payload().downcast_ref::<String>(),
    ) {
        (Some(s), _) => Some(s.to_string()),
        (_, Some(s)) => Some(s.to_string()),
        (None, None) => None,
    };
    let cause = match message {
        Some(m) => m,
        None => "Unknown".into(),
    };
    match panic_info.location() {
        Some(location) => expl.push_str(&format!(
            "Panic occurred in file '{}' at line {}\n",
            location.file(),
            location.line()
        )),
        None => expl.push_str("Panic location unknown.\n"),
    }
    format!("{}\n   {}\n{}", expl, cause, format_backtrace())
}
pub fn format_panic ( panic_info : & PanicInfo ) -> String { let mut expl = String :: new ( ) ; # [ cfg ( feature " " ) ] let message = panic_info . message ( ) . map ( | m | format ! ( " " m ) ) ; # [ cfg ( not ( feature " " ) ) ] let message = match ( panic_info . payload ( ) . downcast_ref :: < & str > ( ) , panic_info . payload ( ) . downcast_ref :: < String > ( ) , ) { ( Some ( s ) , _ ) => Some ( s . to_string ( ) ) , ( _ , Some ( s ) ) => Some ( s . to_string ( ) ) , ( None , None ) => None , } ; let cause = match message { Some ( m ) => m , None => " " . into ( ) , } ; match panic_info . location ( ) { Some ( location ) => expl . push_str ( & format ! ( " \n " location file ( ) location line ( ) ) ) , None => expl . push_str ( " \n " ) , } format ! ( " \n \n " expl cause format_backtrace ( ) ) }
Format the panic message for printing to log
Format the panic message for printing to log
panic_info
&PanicInfo
panic_info
&PanicInfo