Macro std::prelude::panic
Re-export from std::panicking::panic
Ungracefully terminate the thread or process with an error message.
Use this macro to bail on conditions that the program cannot reasonably be expected to recover from (e.g. when a condition means a certain programming bug).
Since panics usually cannot be recovered from, prefer to use structured error handling as a general purpose failure handling mechanism.
Panicking in Alumina does not perform any stack unwinding.
See also spawn for details on how panics are handled in a multithreaded program.
When compiled in debug mode, panic
prints the provided message along with the stack trace (on platforms
that support it)
Example
let value = 42;
switch value % 2 {
0 => println!("even"),
1 => println!("odd"),
_ => panic!("{} is somehow neither odd nor even", value),
}
Run this example
Expressions that unconditionally panic have a never type.