Crate icu_pattern

Source
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!");

Re-exports§

pub use PatternError as Error;

Structs§

MissingNamedPlaceholderError
MultiNamedPlaceholderKey
A string wrapper for the MultiNamedPlaceholder pattern backend.
Parser
Placeholder pattern parser.
ParserOptions
Options passed to the constructor of Parser.
Pattern
A string pattern with placeholders.
PatternString

Enums§

DoublePlaceholder
Backend for patterns containing zero, one, or two placeholders.
DoublePlaceholderKey
A two-value enum for the DoublePlaceholder pattern backend.
MultiNamedPlaceholder
Backend for patterns containing zero or more named placeholders.
ParsedPatternItem
A PatternItem with additional detail returned by the Parser.
ParserError
An error returned when parsing a pattern.
PatternError
PatternItem
A borrowed item in a Pattern. Items are either string literals or placeholders.
PatternItemCow
A borrowed-or-owned item in a Pattern. Items are either string literals or placeholders.
QuoteMode
Controls how quotes (') are interpreted.
SinglePlaceholder
Backend for patterns containing zero or one placeholder.
SinglePlaceholderKey
A singleton enum for the SinglePlaceholder pattern backend.

Traits§

PatternBackend
Types that implement backing data models for Pattern implement this trait.
PlaceholderValueProvider
Trait implemented on collections that can produce [TryWriteable]s for interpolation.

Type Aliases§

DoublePlaceholderPattern
Examples
MultiNamedPlaceholderPattern
Examples
SinglePlaceholderPattern
Examples