Skip to content

Latest commit

 

History

History
33 lines (25 loc) · 764 Bytes

File metadata and controls

33 lines (25 loc) · 764 Bytes

Never type

r[type.never]

r[type.never.syntax]

Syntax
NeverType : !

r[type.never.intro] The never type ! is a type with no values, representing the result of computations that never complete.

Note

Because ! has no values, reading it from memory (or otherwise producing a value of the type at runtime) is immediate undefined behaviour.

r[type.never.coercion] Expressions of type ! can be coerced into any other type.

r[type.never.constraint] The ! type can only appear in function return types presently, indicating it is a diverging function that never returns.

fn foo() -> ! {
    panic!("This call never returns.");
}
unsafe extern "C" {
    pub safe fn no_return_extern_func() -> !;
}