The never type (written as !) is a special type in Rust that represents a function or expression that never returns a value because it either panics or loops infinitely. It is a subtype of every other type, allowing it to be used wherever any other type is expected to satisfy the compiler's type checking requirements.
fn crash() -> ! {
panic!("This function never returns!");
}
fn loop_forever() -> ! {
loop {
// This loop never ends
}
}