Do we have any proposals on extensible enums?

Currently, if we want to use an extensible enum, we can define it as what std::io::Error does

pub enum ErrorKind {
    NotFound,
    PermissionDenied,
    ...,

    #[doc(hidden)]
    __Nonexhaustive,
}

Personally, I don’t like this, because it is more like a hack rather than a formal syntax. Do we have any proposals on extensible enums?

Perhaps we can use _ as a variant in the extensible enums:

pub enum ErrorKind {
    NotFound,
    PermissionDenied,
    ...,
    _,
}

Have you seen the (postponed) RFC 757?

1 Like

Thanks for the link. Is it possible to reopen this RFC for discussion?

There seems to be agreement here that this problem is better solved by privacy, than by a new separate mechanism.

1 Like

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