strum
strum copied to clipboard
Add `EnumDeref` trait and derive
About this PR
This PR introduces a new trait and derive EnumDeref
for automatically implementing Deref
and DerefMut
in enumerators composed of new-type-style variants.
Motivation
The primary motivation for this feature is included as one of the tests and doc-tests: "tagged boxes". With this trait, it's possible to avoid the usage of Box<dyn Trait>
for grouping structs based on behavior. The advantages of using an enum instead of the former are clear as day:
- No pointer access;
- All variants are known at compile time;
- Possibility of using other
strum
macros.