icu_datetime/provider/pattern/item/
generic.rs

1// This file is part of ICU4X. For terms of use, please see the file
2// called LICENSE at the top level of the ICU4X source tree
3// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
4
5/// An element of a [`GenericPattern`](super::super::runtime::GenericPattern).
6///
7/// <div class="stab unstable">
8/// 🚧 This code is considered unstable; it may change at any time, in breaking or non-breaking ways,
9/// including in SemVer minor releases. While the serde representation of data structs is guaranteed
10/// to be stable, their Rust representation might not be. Use with caution.
11/// </div>
12#[derive(Debug, PartialEq, Eq, Clone, Copy)]
13#[cfg_attr(feature = "datagen", derive(serde::Serialize, databake::Bake))]
14#[cfg_attr(feature = "datagen", databake(path = icu_datetime::provider::pattern))]
15#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
16pub enum GenericPatternItem {
17    /// A single digit, 0..=9
18    Placeholder(u8),
19    /// A literal code point
20    Literal(char),
21}
22
23impl From<u8> for GenericPatternItem {
24    fn from(input: u8) -> Self {
25        Self::Placeholder(input)
26    }
27}
28
29impl From<char> for GenericPatternItem {
30    fn from(input: char) -> Self {
31        Self::Literal(input)
32    }
33}