panic!マクロは、パニックを発生させる(アプリケーションを異常終了させる)マクロ。
(JavaのSystem.exit()あるいはErrorのスローに相当)
fn main() {
panic!("panic-test");
}
↓実行例
thread 'main' panicked at src/main.rs:2:5:
panic-test
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: process didn't exit successfully: `target\debug\rust-example1.exe` (exit code: 101)
Optionのunwrap()・expect()やResultのunwrap()・expect()でも、内部ではpanic!()を実行している。