Skip to content

Instantly share code, notes, and snippets.

@toshimasa-nanaki
Created December 2, 2018 04:35
Show Gist options
  • Save toshimasa-nanaki/c4900d70263ff0e05e266a562bfa2240 to your computer and use it in GitHub Desktop.
Save toshimasa-nanaki/c4900d70263ff0e05e266a562bfa2240 to your computer and use it in GitHub Desktop.
Rust 関数(パニック発生)
fn main() {
panic();
//division_by_0();
}
//実行中の現在のスレッドを与えられたメッセージとともにクラッシュさせるマクロを実行
fn panic() -> ! {
panic!("This function never returns!");
}
//0除算(パニック発生の例)
fn division_by_0() -> i32 {
let zero = 0;
3 / zero
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment