Type Alias time::format_description::borrowed_format_item::FormatItem

source ·
pub type FormatItem<'a> = BorrowedFormatItem<'a>;
👎Deprecated since 0.3.35: use BorrowedFormatItem instead for clarity
Available on crate features formatting or parsing only.
Expand description

A complete description of how to format and parse a type.

This alias exists for backwards-compatibility. It is recommended to use BorrowedFormatItem for clarity, as it is more explicit that the data is borrowed rather than owned.

Aliased Type§

enum FormatItem<'a> {
    Literal(&'a [u8]),
    Component(Component),
    Compound(&'a [BorrowedFormatItem<'a>]),
    Optional(&'a BorrowedFormatItem<'a>),
    First(&'a [BorrowedFormatItem<'a>]),
}

Variants§

§

Literal(&'a [u8])

Bytes that are formatted as-is.

Note: These bytes should be UTF-8, but are not required to be. The value is passed through String::from_utf8_lossy when necessary.

§

Component(Component)

A minimal representation of a single non-literal item.

§

Compound(&'a [BorrowedFormatItem<'a>])

A series of literals or components that collectively form a partial or complete description.

§

Optional(&'a BorrowedFormatItem<'a>)

A FormatItem that may or may not be present when parsing. If parsing fails, there will be no effect on the resulting struct.

This variant has no effect on formatting, as the value is guaranteed to be present.

§

First(&'a [BorrowedFormatItem<'a>])

A series of FormatItems where, when parsing, the first successful parse is used. When formatting, the first element of the slice is used. An empty slice is a no-op when formatting or parsing.