Expand description
icu_pattern
is a utility crate of the ICU4X
project.
It includes a Pattern
type which supports patterns with various storage backends.
The types are tightly coupled with the writeable
crate.
§Examples
Parsing and interpolating with a single-placeholder pattern:
use icu_pattern::SinglePlaceholderPattern;
use writeable::assert_writeable_eq;
// Parse a pattern string:
let pattern = SinglePlaceholderPattern::try_from_str("Hello, {0}!", Default::default())
.unwrap();
// Interpolate into the pattern string:
assert_writeable_eq!(pattern.interpolate(["World"]), "Hello, World!");
Structs§
- A string wrapper for the
MultiNamedPlaceholder
pattern backend. - Placeholder pattern parser.
- Options passed to the constructor of
Parser
. - A string pattern with placeholders.
Enums§
- Backend for patterns containing zero, one, or two placeholders.
- A two-value enum for the
DoublePlaceholder
pattern backend. - Backend for patterns containing zero or more named placeholders.
- A
PatternItem
with additional detail returned by theParser
. - An error returned when parsing a pattern.
- A borrowed item in a
Pattern
. Items are either string literals or placeholders. - A borrowed-or-owned item in a
Pattern
. Items are either string literals or placeholders. - Controls how quotes (
'
) are interpreted. - Backend for patterns containing zero or one placeholder.
- A singleton enum for the
SinglePlaceholder
pattern backend.
Constants§
- Default annotation for the literal portion of a pattern.
- Default annotation for the placeholder portion of a pattern.
Traits§
- Types that implement backing data models for
Pattern
implement this trait. - Trait implemented on collections that can produce
TryWriteable
s for interpolation.
Type Aliases§
- Examples
- Examples
- Examples