diff options
| author | Mara Bos <m-ou.se@m-ou.se> | 2020-07-22 12:17:36 +0200 |
|---|---|---|
| committer | Mara Bos <m-ou.se@m-ou.se> | 2020-10-18 12:25:26 +0200 |
| commit | 01b0aff1df1dd5ee7c60e8fbeff15cc3edaa3208 (patch) | |
| tree | f4cb545840fb82c1369ffd9123960f5b0aa3366a /library/std/src/panic.rs | |
| parent | dda2b5e3e260c14b868c494008af1c8981eaa5a8 (diff) | |
| download | rust-01b0aff1df1dd5ee7c60e8fbeff15cc3edaa3208.tar.gz rust-01b0aff1df1dd5ee7c60e8fbeff15cc3edaa3208.zip | |
Add std::panic::panic_box.
Diffstat (limited to 'library/std/src/panic.rs')
| -rw-r--r-- | library/std/src/panic.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/library/std/src/panic.rs b/library/std/src/panic.rs index 4281867314c..06ce66c10f7 100644 --- a/library/std/src/panic.rs +++ b/library/std/src/panic.rs @@ -23,6 +23,20 @@ pub use crate::panicking::{set_hook, take_hook}; #[stable(feature = "panic_hooks", since = "1.10.0")] pub use core::panic::{Location, PanicInfo}; +/// Panic the current thread, with the given payload as the panic message. +/// +/// This supports an arbitrary panic payload, instead of just (formatted) strings. +/// +/// The message is attached as a `Box<'static + Any + Send>`, which can be +/// accessed using [`PanicInfo::payload`]. +/// +/// See the [`panic!`] macro for more information about panicking. +#[unstable(feature = "panic_box", issue = "none")] +#[inline] +pub fn panic_box<M: Any + Send>(msg: M) -> ! { + crate::panicking::begin_panic(msg); +} + /// A marker trait which represents "panic safe" types in Rust. /// /// This trait is implemented by default for many types and behaves similarly in |
