What is the never type in Rust

The never type (!) in Rust represents code that never returns, such as panics or infinite loops, and acts as a subtype of all other types.

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
    }
}