Created
December 2, 2018 04:35
-
-
Save toshimasa-nanaki/c4900d70263ff0e05e266a562bfa2240 to your computer and use it in GitHub Desktop.
Rust 関数(パニック発生)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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