Skip to main content

ferro_markup_enum

Macro ferro_markup_enum 

Source
macro_rules! ferro_markup_enum {
    ($type_:ident { $($member:ident $(= $variant:ident)?),* $(,)? } $(, { $($body:tt)* })?) => { ... };
    (flags $type_:ident { $($member:ident = $value:expr),* $(,)? } $(, { $($body:tt)* })?) => { ... };
}
Expand description

Declares the markup metadata of an enumeration: its members by name.

ⓘ
ferro_markup_enum!(Dock { Left, Bottom, Right, Top });

// A member whose Rust variant has another name (`Self` is reserved):
ferro_markup_enum!(RelativeSourceMode { DataContext, TemplatedParent, Self = Self_, FindAncestor });

// A set of flags (a `bitflags!` type): members name their constants.
ferro_markup_enum!(flags RoutingStrategies {
    Direct = RoutingStrategies::DIRECT,
    Tunnel = RoutingStrategies::TUNNEL,
    Bubble = RoutingStrategies::BUBBLE,
});

// With attributes or another namespace:
ferro_markup_enum!(Dock { Left, Bottom, Right, Top }, { namespace: "FerroUI.Controls" });

The members of a plain enumeration are its variants (their numeric value is the discriminant); the members of a flags type are constants with a bits() method. The untyped form of a member is a value of the type itself. Implements MarkupTyped.