std::panic!
[−]
[src]
macro_rules! panic { () => ({ panic!("explicit panic") }); ($msg:expr) => ({ $crate::rt::begin_unwind($msg, { // static requires less code at runtime, more constant data static _FILE_LINE: (&'static str, u32) = (file!(), line!()); &_FILE_LINE }) }); ($fmt:expr, $($arg:tt)+) => ({ $crate::rt::begin_unwind_fmt(format_args!($fmt, $($arg)+), { // The leading _'s are to avoid dead code warnings if this is // used inside a dead function. Just `#[allow(dead_code)]` is // insufficient, since the user may have // `#[forbid(dead_code)]` and which cannot be overridden. static _FILE_LINE: (&'static str, u32) = (file!(), line!()); &_FILE_LINE }) }); }
The entry point for panic of Rust threads.
This macro is used to inject panic into a Rust thread, causing the thread to
unwind and panic entirely. Each thread's panic can be reaped as the
Box<Any>
type, and the single-argument form of the panic!
macro will be
the value which is transmitted.
The multi-argument form of this macro panics with a string and has the
format!
syntax for building a string.
Examples
fn main() { #![allow(unreachable_code)] panic!(); panic!("this is a terrible mistake!"); panic!(4); // panic with the value of 4 to be collected elsewhere panic!("this is a {} {message}", "fancy", message = "message"); }panic!(); panic!("this is a terrible mistake!"); panic!(4); // panic with the value of 4 to be collected elsewhere panic!("this is a {} {message}", "fancy", message = "message");
The entry point for panic of Rust threads.
This macro is used to inject panic into a Rust thread, causing the thread to
unwind and panic entirely. Each thread's panic can be reaped as the
Box<Any>
type, and the single-argument form of the panic!
macro will be
the value which is transmitted.
The multi-argument form of this macro panics with a string and has the
format!
syntax for building a string.
Examples
fn main() { #![allow(unreachable_code)] panic!(); panic!("this is a terrible mistake!"); panic!(4); // panic with the value of 4 to be collected elsewhere panic!("this is a {} {message}", "fancy", message = "message"); }panic!(); panic!("this is a terrible mistake!"); panic!(4); // panic with the value of 4 to be collected elsewhere panic!("this is a {} {message}", "fancy", message = "message");