Exclude

Derive Macro Exclude 

Source
#[derive(Exclude)]
{
    // Attributes available to this derive:
    #[exclude]
}
Expand description

Constructs enums by excluding the set of variants from the original enum.

§Example

#[derive(Exclude)]
#[exclude(arg(ident = ExcludeMercury, variants(Mercury)))]
pub enum Planet {
    Mercury,
    Venus,
    Earth,
    Mars,
}

The above code will generate the following enum:

pub enum ExcludeMercury {
    Venus,
    Earth,
    Mars,
}

§Attributes

#[derive(Exclude)]
#[exclude(
    [forward_attrs(<ATTR, ...> | not(<ATTR, ...>))], // Forward specific attributes to all generated enums
    arg(
        ident = <IDENT>, // The identifier of the generated enum
        variants(<VARIANT>, ...), // The variants to exclude from the original enum
        [derive(<DERIVE>, ...)], // Derive attributes for the generated enum
        [forward_attrs(<ATTR, ...> | not(<ATTR, ...>))], // Forward specific attributes to the generated enum
            // If given, will override the container level `forward_attrs`
    ),
)]
pub enum BasedEnum {
    #[exclude(
        [forward_attrs(<ATTR, ...> | not(<ATTR, ...>))], // Forward specific attributes to the generated variant
            // If given, will override the container level and arg level `forward_attrs`
    )]
    variant: VariantType,
}