#[derive(Encapsulate)]
{
// Attributes available to this derive:
#[enumcapsulate]
}
Expand description
Umbrella derive macro.
The following use of the Encapsulate
umbrella derive macro:
ⓘ
use enumcapsulate::Encapsulate;
#[derive(Encapsulate)
enum Enum {
// ...
}
is equivalent to the following:
ⓘ
// ...
#[derive(
From,
TryInto,
FromVariant,
IntoVariant,
AsVariant,
AsVariantMut,
AsVariantRef,
VariantDowncast,
)]
enum Enum {
// ...
}
If you wish to opt out of a select few of Encapsulate
’s trait derives,
then you can do so by use of an #[enumcapsulate(exclude(…))]
attribute
on the enum itself, such as if you wanted to exclude From
and TryInto
:
#[derive(Encapsulate)]
#[enumcapsulate(exclude(From, TryInto))]
enum Enum {
// ...
}