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 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§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<'_>
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.§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.§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
§fn write_to_string(&self) -> Cow<'_, str>
fn write_to_string(&self) -> Cow<'_, str>
Creates a new
String
with the data from this Writeable
. Like ToString
,
but smaller and faster. Read moresource§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§unsafe fn make(this: Self::Output) -> Self
unsafe fn make(this: Self::Output) -> Self
This method can be used to cast away
Self<'a>
’s lifetime. Read moresource§fn transform_mut<F>(&'a mut self, f: F)where
F: 'static + for<'b> FnOnce(&'b mut Self::Output),
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 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>) -> 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§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