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<'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§fn default() -> GenericPattern<'_>
fn default() -> GenericPattern<'_>
Returns the “default value” for a type. Read more
source§impl<'de, 'data> Deserialize<'de> for GenericPattern<'data>where
'de: 'data,
impl<'de, 'data> Deserialize<'de> for GenericPattern<'data>where
'de: 'data,
source§fn deserialize<D>(
deserializer: D,
) -> Result<GenericPattern<'data>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<GenericPattern<'data>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl Display for GenericPattern<'_>
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<'_>) -> GenericPattern
fn from(input: &GenericPattern<'_>) -> GenericPattern
Converts to this type from the input type.
source§impl From<&GenericPattern> for GenericPattern<'_>
impl From<&GenericPattern> for GenericPattern<'_>
source§fn from(input: &GenericPattern) -> GenericPattern<'_>
fn from(input: &GenericPattern) -> GenericPattern<'_>
Converts to this type from the input type.
source§impl FromStr for GenericPattern<'_>
impl FromStr for GenericPattern<'_>
source§type Err = PatternError
type Err = PatternError
The associated error which can be returned from parsing.
source§fn from_str(
s: &str,
) -> Result<GenericPattern<'_>, <GenericPattern<'_> as FromStr>::Err>
fn from_str( s: &str, ) -> Result<GenericPattern<'_>, <GenericPattern<'_> as FromStr>::Err>
Parses a string
s
to return a value of this type. Read moresource§impl<'data> PartialEq for GenericPattern<'data>
impl<'data> PartialEq for GenericPattern<'data>
source§impl Serialize for GenericPattern<'_>
impl Serialize for GenericPattern<'_>
source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
source§impl Writeable for GenericPattern<'_>
impl Writeable for GenericPattern<'_>
source§fn write_to<W>(&self, formatter: &mut W) -> Result<(), Error>
fn write_to<W>(&self, formatter: &mut W) -> Result<(), Error>
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) -> <GenericPattern<'static> as Yokeable<'a>>::Output
fn transform_owned(self) -> <GenericPattern<'static> as Yokeable<'a>>::Output
source§unsafe fn make(
this: <GenericPattern<'static> as Yokeable<'a>>::Output,
) -> GenericPattern<'static>
unsafe fn make( this: <GenericPattern<'static> as Yokeable<'a>>::Output, ) -> GenericPattern<'static>
This method can be used to cast away
Self<'a>
’s lifetime. Read moresource§fn transform_mut<F>(&'a mut self, f: F)
fn transform_mut<F>(&'a mut self, f: F)
This method must cast
self
between &'a mut Self<'static>
and &'a mut Self<'a>
,
and pass it to f
. Read moresource§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>) -> GenericPattern<'zf>
fn zero_from(this: &'zf GenericPattern<'zf_inner>) -> GenericPattern<'zf>
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)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