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 GenericPatternItem
s.
Implementationsยง
Sourceยงimpl GenericPattern<'_>
impl GenericPattern<'_>
Sourceยงimpl<'data> GenericPattern<'data>
impl<'data> GenericPattern<'data>
Sourcepub fn combined(
self,
date: Pattern<'data>,
time: Pattern<'data>,
) -> Result<Pattern<'static>, PatternError>
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>
impl<'data> Bake for GenericPattern<'data>
Sourceยงfn bake(&self, env: &CrateEnv) -> TokenStream
fn bake(&self, env: &CrateEnv) -> TokenStream
Sourceยงimpl<'data> BakeSize for GenericPattern<'data>
impl<'data> BakeSize for GenericPattern<'data>
Sourceยงfn borrows_size(&self) -> usize
fn borrows_size(&self) -> usize
Returns the size
Sourceยงimpl<'data> Clone for GenericPattern<'data>
impl<'data> Clone for GenericPattern<'data>
Sourceยงfn clone(&self) -> GenericPattern<'data>
fn clone(&self) -> GenericPattern<'data>
Returns a copy of the value. Read more
1.0.0 ยท Sourceยงfn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSourceยงimpl<'data> Debug for GenericPattern<'data>
impl<'data> Debug for GenericPattern<'data>
Sourceยงimpl Default for GenericPattern<'_>
impl Default for GenericPattern<'_>
Sourceยงimpl<'de: 'data, 'data> Deserialize<'de> for GenericPattern<'data>
impl<'de: 'data, 'data> Deserialize<'de> for GenericPattern<'data>
Sourceยงfn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
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.
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ยงimpl From<&GenericPattern<'_>> for GenericPattern
impl From<&GenericPattern<'_>> for GenericPattern
Sourceยงfn from(input: &GenericPattern<'_>) -> Self
fn from(input: &GenericPattern<'_>) -> Self
Converts to this type from the input type.
Sourceยงimpl From<&GenericPattern> for GenericPattern<'_>
impl From<&GenericPattern> for GenericPattern<'_>
Sourceยงfn from(input: &GenericPattern) -> Self
fn from(input: &GenericPattern) -> Self
Converts to this type from the input type.
Sourceยงimpl FromStr for GenericPattern<'_>
impl FromStr for GenericPattern<'_>
Sourceยงimpl<'data> PartialEq for GenericPattern<'data>
impl<'data> PartialEq for GenericPattern<'data>
Sourceยงimpl Serialize for GenericPattern<'_>
impl Serialize for GenericPattern<'_>
Sourceยงimpl Writeable for GenericPattern<'_>
impl Writeable for GenericPattern<'_>
Sourceยงfn write_to<W: Write + ?Sized>(&self, formatter: &mut W) -> Result
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.Sourceยงfn write_to_parts<S>(&self, sink: &mut S) -> Result<(), Error>where
S: PartsWrite + ?Sized,
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.Sourceยงfn writeable_length_hint(&self) -> LengthHint
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
Sourceยงimpl<'a> Yokeable<'a> for GenericPattern<'static>
impl<'a> Yokeable<'a> for GenericPattern<'static>
Sourceยงtype Output = GenericPattern<'a>
type Output = GenericPattern<'a>
This type MUST be
Self
with the 'static
replaced with 'a
, i.e. Self<'a>
Sourceยงfn transform_owned(self) -> Self::Output
fn transform_owned(self) -> Self::Output
Sourceยงimpl<'zf, 'zf_inner> ZeroFrom<'zf, GenericPattern<'zf_inner>> for GenericPattern<'zf>
impl<'zf, 'zf_inner> ZeroFrom<'zf, GenericPattern<'zf_inner>> for GenericPattern<'zf>
Sourceยงfn zero_from(this: &'zf GenericPattern<'zf_inner>) -> Self
fn zero_from(this: &'zf GenericPattern<'zf_inner>) -> Self
Clone the other
C
into a struct that may retain references into C
.impl<'data> Eq for GenericPattern<'data>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Sourceยงfn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Sourceยงimpl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Sourceยงimpl<T> IntoEither for T
impl<T> IntoEither for T
Sourceยงfn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSourceยงfn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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