amass
Automatically generate From impls for nested enums, even across crates.
All that is required is an attribute applied to each nesting enum:
Example
use Letter;
use Number;
;
amass is powered by telety,
which still has limitations in the language features it supports.
You can use the #[amass] and #[telety(...)] attributes separately,
or simply use the combined #[amass_telety(...)] attribute.
Specifying implementations
amass has customizable behavior for applicable fields. The following options exist:
- ignore - No From impl will be created for the field type or the field types contained within that type.
- shallow - A From impl will be created for the field type, but not for any field types contained within that type.
- deep - A From impl will be created for the field type, and if that type is telety-enabled, for the the field types contained within that type.
- force - A From impl will be created for the field type and for the the field types contained within that type. If the type is not telety-enabled, a compile error will be generated.
A default action can be specified on the main attribute: #[amass(default = force)].
If no default is provided on the attribute, deep is the default action.
This default can be overriden on specific variants with the #[amass_action(...)] helper attribute.
Note that is not currently possible to override behavior on an upstream enum.
In this example, two impls for From<DiamondTop> for DiamondBottom are generated, causing a compile error.
# use amass_telety;
;
#
To solve this, either DiamondLeft or DiamondRight must ignore the Top variant,
or DiamondBottom must use shallow for the Left or Right variant. It is not possible to only skip
the DiamondTop -> DiamondLeft/DiamondRight -> DiamondBottom impl.