std::panic

Macro std::panic

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

© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/std/macro.panic.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部