Struct icu_datetime::provider::pattern::runtime::GenericPattern

source ·
pub struct GenericPattern<'data> {
    pub items: ZeroVec<'data, GenericPatternItem>,
}
Expand description

A raw, low-level pattern with literals and placeholders.

This is a datetime-specific type designed to be binary-compatible with Pattern. ICU4X developers looking for this sort of type should use the icu_pattern crate instead.

🚧 This code is considered unstable; it may change at any time, in breaking or non-breaking ways, including in SemVer minor releases. While the serde representation of data structs is guaranteed to be stable, their Rust representation might not be. Use with caution.

Fields§

§items: ZeroVec<'data, GenericPatternItem>

The list of GenericPatternItems.

Implementations§

source§

impl<'data> GenericPattern<'data>

source

pub fn combined( self, date: Pattern<'data>, time: Pattern<'data>, ) -> Result<Pattern<'static>, PatternError>

The function allows for creation of new DTF pattern from a generic pattern and replacement patterns.

§Examples
use icu::datetime::provider::pattern::runtime::{GenericPattern, Pattern};

let date: Pattern = "y-M-d".parse().expect("Failed to parse pattern");
let time: Pattern = "HH:mm".parse().expect("Failed to parse pattern");

let glue: GenericPattern = "{1} 'at' {0}"
    .parse()
    .expect("Failed to parse generic pattern");
assert_eq!(
    glue.combined(date, time)
        .expect("Failed to combine patterns")
        .to_string(),
    "y-M-d 'at' HH:mm"
);

Trait Implementations§

source§

impl<'data> Bake for GenericPattern<'data>

source§

fn bake(&self, env: &CrateEnv) -> TokenStream

Returns a TokenStream that would evaluate to self. Read more
source§

impl<'data> BakeSize for GenericPattern<'data>

source§

fn borrows_size(&self) -> usize

Returns the size
source§

impl<'data> Clone for GenericPattern<'data>

source§

fn clone(&self) -> GenericPattern<'data>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'data> Debug for GenericPattern<'data>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for GenericPattern<'_>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<'de: 'data, 'data> Deserialize<'de> for GenericPattern<'data>

source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for GenericPattern<'_>

This trait is implemented for compatibility with fmt!. To create a string, [Writeable::write_to_string] is usually more efficient.

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<&GenericPattern<'_>> for GenericPattern

source§

fn from(input: &GenericPattern<'_>) -> Self

Converts to this type from the input type.
source§

impl From<&GenericPattern> for GenericPattern<'_>

source§

fn from(input: &GenericPattern) -> Self

Converts to this type from the input type.
source§

impl FromStr for GenericPattern<'_>

source§

type Err = PatternError

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
source§

impl<'data> PartialEq for GenericPattern<'data>

source§

fn eq(&self, other: &GenericPattern<'data>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for GenericPattern<'_>

source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Writeable for GenericPattern<'_>

source§

fn write_to<W: Write + ?Sized>(&self, formatter: &mut W) -> Result

Writes a string to the given sink. Errors from the sink are bubbled up. The default implementation delegates to write_to_parts, and discards any Part annotations.
§

fn write_to_parts<S>(&self, sink: &mut S) -> Result<(), Error>
where S: PartsWrite + ?Sized,

Write bytes and Part annotations to the given sink. Errors from the sink are bubbled up. The default implementation delegates to write_to, and doesn’t produce any Part annotations.
§

fn writeable_length_hint(&self) -> LengthHint

Returns a hint for the number of UTF-8 bytes that will be written to the sink. Read more
§

fn write_to_string(&self) -> Cow<'_, str>

Creates a new String with the data from this Writeable. Like ToString, but smaller and faster. Read more
source§

impl<'a> Yokeable<'a> for GenericPattern<'static>

source§

type Output = GenericPattern<'a>

This type MUST be Self with the 'static replaced with 'a, i.e. Self<'a>
source§

fn transform(&'a self) -> &'a Self::Output

This method must cast self between &'a Self<'static> and &'a Self<'a>. Read more
source§

fn transform_owned(self) -> Self::Output

This method must cast self between Self<'static> and Self<'a>. Read more
source§

unsafe fn make(this: Self::Output) -> Self

This method can be used to cast away Self<'a>’s lifetime. Read more
source§

fn transform_mut<F>(&'a mut self, f: F)
where F: 'static + for<'b> FnOnce(&'b mut Self::Output),

This method must cast self between &'a mut Self<'static> and &'a mut Self<'a>, and pass it to f. Read more
source§

impl<'zf, 'zf_inner> ZeroFrom<'zf, GenericPattern<'zf_inner>> for GenericPattern<'zf>

source§

fn zero_from(this: &'zf GenericPattern<'zf_inner>) -> Self

Clone the other C into a struct that may retain references into C.
source§

impl<'data> Eq for GenericPattern<'data>

source§

impl<'data> StructuralPartialEq for GenericPattern<'data>

Auto Trait Implementations§

§

impl<'data> Freeze for GenericPattern<'data>

§

impl<'data> RefUnwindSafe for GenericPattern<'data>

§

impl<'data> Send for GenericPattern<'data>

§

impl<'data> Sync for GenericPattern<'data>

§

impl<'data> Unpin for GenericPattern<'data>

§

impl<'data> UnwindSafe for GenericPattern<'data>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> Serialize for T
where T: Serialize + ?Sized,

source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<Ok, Error>

source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T
where T: Send + Sync,