Enum time::format_description::FormatItem
source · [−]#[non_exhaustive]
pub enum FormatItem<'a> {
Literal(&'a [u8]),
Component(Component),
Compound(&'a [Self]),
Optional(&'a Self),
First(&'a [Self]),
}
formatting
or parsing
only.Expand description
A complete description of how to format and parse a type.
Variants (Non-exhaustive)
This enum is marked as non-exhaustive
Literal(&'a [u8])
Bytes that are formatted as-is.
Note: If you call the format
method that returns a String
, these bytes will be
passed through String::from_utf8_lossy
.
Component(Component)
A minimal representation of a single non-literal item.
Compound(&'a [Self])
A series of literals or components that collectively form a partial or complete description.
Optional(&'a Self)
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 [Self])
A series of FormatItem
s 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.
Trait Implementations
sourceimpl<'a> Clone for FormatItem<'a>
impl<'a> Clone for FormatItem<'a>
sourcefn clone(&self) -> FormatItem<'a>ⓘNotable traits for FormatItem<'_>impl Formattable for FormatItem<'_>impl Parsable for FormatItem<'_>
fn clone(&self) -> FormatItem<'a>ⓘNotable traits for FormatItem<'_>impl Formattable for FormatItem<'_>impl Parsable for FormatItem<'_>
1.0.0 · sourceconst fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read moresourceimpl Debug for FormatItem<'_>
Available on crate feature alloc
only.
impl Debug for FormatItem<'_>
alloc
only.sourceimpl<'a> From<&'a [FormatItem<'_>]> for FormatItem<'a>
impl<'a> From<&'a [FormatItem<'_>]> for FormatItem<'a>
sourcefn from(items: &'a [FormatItem<'_>]) -> FormatItem<'a>ⓘNotable traits for FormatItem<'_>impl Formattable for FormatItem<'_>impl Parsable for FormatItem<'_>
fn from(items: &'a [FormatItem<'_>]) -> FormatItem<'a>ⓘNotable traits for FormatItem<'_>impl Formattable for FormatItem<'_>impl Parsable for FormatItem<'_>
sourceimpl From<Component> for FormatItem<'_>
impl From<Component> for FormatItem<'_>
sourceimpl PartialEq<&[FormatItem<'_>]> for FormatItem<'_>
impl PartialEq<&[FormatItem<'_>]> for FormatItem<'_>
sourcefn eq(&self, rhs: &&[FormatItem<'_>]) -> bool
fn eq(&self, rhs: &&[FormatItem<'_>]) -> bool
sourceimpl PartialEq<FormatItem<'_>> for &[FormatItem<'_>]
impl PartialEq<FormatItem<'_>> for &[FormatItem<'_>]
sourcefn eq(&self, rhs: &FormatItem<'_>) -> bool
fn eq(&self, rhs: &FormatItem<'_>) -> bool
sourceimpl PartialEq<FormatItem<'_>> for Component
impl PartialEq<FormatItem<'_>> for Component
sourcefn eq(&self, rhs: &FormatItem<'_>) -> bool
fn eq(&self, rhs: &FormatItem<'_>) -> bool
sourceimpl<'a> PartialEq<FormatItem<'a>> for FormatItem<'a>
impl<'a> PartialEq<FormatItem<'a>> for FormatItem<'a>
sourcefn eq(&self, other: &FormatItem<'a>) -> bool
fn eq(&self, other: &FormatItem<'a>) -> bool
sourceimpl TryFrom<FormatItem<'_>> for Component
impl TryFrom<FormatItem<'_>> for Component
type Error = DifferentVariant
type Error = DifferentVariant
sourcefn try_from(value: FormatItem<'_>) -> Result<Self, Self::Error>
fn try_from(value: FormatItem<'_>) -> Result<Self, Self::Error>
sourceimpl<'a> TryFrom<FormatItem<'a>> for &[FormatItem<'a>]
impl<'a> TryFrom<FormatItem<'a>> for &[FormatItem<'a>]
type Error = DifferentVariant
type Error = DifferentVariant
sourcefn try_from(value: FormatItem<'a>) -> Result<Self, Self::Error>
fn try_from(value: FormatItem<'a>) -> Result<Self, Self::Error>
impl<'a> Eq for FormatItem<'a>
impl Formattable for FormatItem<'_>
formatting
only.impl Parsable for FormatItem<'_>
parsing
only.