Looking at question number 3 here.
As an example, I've edited as such.
fn main() {
never_return();
// println!("Failed!");
}
fn never_return() -> ! {
// Implement this function, don't modify the fn signatures
panic!("stop")
}
The expectation when returning something from a fn is without a trailing ;
. In the above case, the panic!(_)
returns a type never
and does what I would expect it to. However, the same fn signature, returning !
, compiles to the same regardless of whether there is a ;
after the panic
macro or not. I'm assuming this is the case because of the intrinsics of a panic
? But couldn't find a technical explanation to it that I understood.
Why is this the case?