std::panic - Rust
Description: API documentation for the Rust `panic` macro in crate `std`.
Keywords: rust, rustlang, rust-lang, panic

# Macro std::panic 1.0.0 [−] [src]

    macro_rules! panic {
        () => { ... };
        ($msg:expr) => { ... };
        ($fmt:expr, $($arg:tt)+) => { ... };
    }

The entry point for panic of Rust threads.

This macro is used to inject panic into a Rust thread, causing the thread to 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

    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");Run

# Help

## Keyboard Shortcuts

?
  Show this help dialog
S
  Focus the search field
⇤
  Move up in search results
⇥
  Move down in search results
⏎
  Go to active search result
+
  Collapse/expand all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)