Skip to content

Commit 01b0aff

Browse files
committed
Add std::panic::panic_box.
1 parent dda2b5e commit 01b0aff

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

library/std/src/panic.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,20 @@ pub use crate::panicking::{set_hook, take_hook};
2323
#[stable(feature = "panic_hooks", since = "1.10.0")]
2424
pub use core::panic::{Location, PanicInfo};
2525

26+
/// Panic the current thread, with the given payload as the panic message.
27+
///
28+
/// This supports an arbitrary panic payload, instead of just (formatted) strings.
29+
///
30+
/// The message is attached as a `Box<'static + Any + Send>`, which can be
31+
/// accessed using [`PanicInfo::payload`].
32+
///
33+
/// See the [`panic!`] macro for more information about panicking.
34+
#[unstable(feature = "panic_box", issue = "none")]
35+
#[inline]
36+
pub fn panic_box<M: Any + Send>(msg: M) -> ! {
37+
crate::panicking::begin_panic(msg);
38+
}
39+
2640
/// A marker trait which represents "panic safe" types in Rust.
2741
///
2842
/// This trait is implemented by default for many types and behaves similarly in

0 commit comments

Comments
 (0)