Hacker News new | ask | show | jobs
by ElderKorihor 1813 days ago
> Only if you're willing to accept undefined behavior if the foreign code passes you an unknown variant.

Isn't that what `#[non_exhaustive]` is for?

1 comments

As far as I know that flag doesn't give you permission to create unknown variants or effect backend code generation that will assume there are only the defined variants. I could be wrong, but I don't see anything about this documented in the rfc: https://rust-lang.github.io/rfcs/2008-non-exhaustive.html