Skip to main content

PanicPayload

Trait PanicPayload 

Source
pub trait PanicPayload: Display {
    // Required methods
    fn take_box(&mut self) -> Box<dyn Any + Send>;
    fn get(&mut self) -> &(dyn Any + Send);

    // Provided method
    fn as_str(&mut self) -> Option<&str> { ... }
}
🔬This is a nightly-only experimental API. (std_internals)
Expand description

An internal trait used by std to pass data from std to panic_unwind and other panic runtimes. Not intended to be stabilized any time soon, do not use.

Required Methods§

Source

fn take_box(&mut self) -> Box<dyn Any + Send>

🔬This is a nightly-only experimental API. (std_internals)

Take full ownership of the contents.

After this method got called, only some dummy default value is left in self. Calling this method twice, or calling get after calling this method, is an error.

The argument is borrowed because the panic runtime (__rust_start_panic) only gets a borrowed dyn PanicPayload.

Source

fn get(&mut self) -> &(dyn Any + Send)

🔬This is a nightly-only experimental API. (std_internals)

Just borrow the contents.

Provided Methods§

Source

fn as_str(&mut self) -> Option<&str>

🔬This is a nightly-only experimental API. (std_internals)

Tries to borrow the contents as &str, if possible without doing any allocations.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§