Macro time::format_description::parse::format_item::modifier

source ·
macro_rules! modifier {
    ($(
        enum $name:ident $(($target_ty:ty))? {
            $(
                $(#[$attr:meta])?
                $variant:ident $(($target_value:expr))? = $parse_variant:literal
            ),* $(,)?
        }
    )+) => { ... };
}
Available on (crate features formatting or parsing) and crate feature alloc only.
Expand description

Declare the various modifiers.

For the general case, ordinary syntax can be used. Note that you must declare a default variant. The only significant change is that the string representation of the variant must be provided after the variant name. For example, Numerical = b"numerical" declares a variant named Numerical with the string representation b"numerical". This is the value that will be used when parsing the modifier. The value is not case sensitive.

If the type in the public API does not have the same name as the type in the internal representation, then the former must be specified in parenthesis after the internal name. For example, HourBase(bool) has an internal name “HourBase”, but is represented as a boolean in the public API.

By default, the internal variant name is assumed to be the same as the public variant name. If this is not the case, the qualified path to the variant must be specified in parenthesis after the internal variant name. For example, Twelve(true) has an internal variant name “Twelve”, but is represented as true in the public API.