Is there an attribute to throw a compiler error when a specific enum variant is constructed?
I had this issue where I could not use a generic type parameter on an enum because of the error R: parameter is never used
:
enum Msg<R: Route, P: Page<R>> {
Page(<P as Component>::Msg),
UrlChanged(subs::UrlChanged),
}
So I added a phantom variant, which should never be used:
enum Msg<R: Route, P: Page<R>> {
Page(<P as Component>::Msg),
UrlChanged(subs::UrlChanged),
_Unreachable(std::marker::PhantomData<R>),
}
How can I tell the compiler to throw an error when this variant is constructed, or maybe even used in a pattern?