#[varflags]Expand description
Attribute marking an enum declaration as input for Varflags.
This attribute requires a unit-only enum with more than 0 variants and all of the variants’ discriminants should have exactly one bit set. It can’t have more than 128 variants.
It does exactly this list of things:
- Derives [
Clone] for the enum. It is required, so you don’t have to derive or implement it manually. - Adds
#[repr]attribute for the enum which can be set to eitheru8,u16,u32,u64oru128.
Keep in mind, that#[repr(u128)]is currently unstable. - Consumes
#[flag]and#[shift]variant attributes and sets their variants’ discriminants accordingly. - Calculates and asigns unused discriminants for variants wihout explicit discriminants or attributes.
- Creates a private module called after enum name converted to snake case with _varflags appended.
- Generates [
From] implementation for representing (unsigned integer) type from the enum. - Generates [
Not][core::ops::Not], [BitAnd][core::ops::BitAnd], [BitOr][core::ops::BitOr] and [BitXor][core::ops::BitXor] for the enum, with output beingVarflagsstruct, withEbeing input enum andBbeing one of the built-in [bitworks] bitsets with correct representation. - Generates [
TryFrom] implementation for input enum from [bitworks::index::Index] (for the correctBitset). - Generates [
core::fmt::Display] for input enum, which just outputs a stringified variant name. - Re-exports a type alias for
Varflagsspecific for input enum named as the name of input enum’s name with “Varflags” appended. The re-export will have the same visibility as the enum.