Can an empty enum replace the exclaimation symbol as the never type?

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Never {}

In hindsight, an empty enum acts similar to the ! type. If this is true, then we could use it as the never type and reserve the ! symbol for other purposes.

! can already be used in function return types on stable.

1 Like

The builtin ! type also has interesting coercion rules, which is part of the concern about stabilizing it.


Indeed. And Infallible in std::convert - Rust is the canonical version of such that's stable in the library today.

The road to stabilizing ! as a type is still on-going. There's a plan to have a new meeting about it soon™.


This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.