#[enum_dispatch]
Expand description

Annotating a trait or enum definition with an #[enum_dispatch] attribute will register it with the enum_dispatch library, allowing it to be used to generate impl blocks elsewhere.

Annotating a trait or enum definition with an #[enum_dispatch(BlockName)] attribute will generate an enum dispatch implementation for the specified trait/enum pair, as well as adding an impl of std::convert::From for each variant. When annotating a trait, BlockName should be the name of a registered enum. When annotating an enum, BlockName should be the name of a registered trait.

An annotated enum should have variants that are simply the names of types imported to the current scope. To force individual variants to use a custom name when expanded, each variant can also take the form of a normal tuple-style enum variant with a single field.