Do we have any proposals on extensible enums?

#1

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,
    ...,
    _,
}
#2

Have you seen the (postponed) RFC 757?

1 Like
#3

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

#4

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

1 Like
closed #5

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