| 1 |
# icu_pattern [](https://crates.io/crates/icu_pattern) |
| 2 |
|
| 3 |
<!-- cargo-rdme start --> |
| 4 |
|
| 5 |
`icu_pattern` is a utility crate of the [`ICU4X`] project. |
| 6 |
|
| 7 |
It includes a [`Pattern`] type which supports patterns with various storage backends. |
| 8 |
|
| 9 |
The types are tightly coupled with the [`writeable`] crate. |
| 10 |
|
| 11 |
## Examples |
| 12 |
|
| 13 |
Parsing and interpolating with a single-placeholder pattern: |
| 14 |
|
| 15 |
```rust |
| 16 |
use icu_pattern::SinglePlaceholderPattern; |
| 17 |
use writeable::assert_writeable_eq; |
| 18 |
|
| 19 |
// Parse a pattern string: |
| 20 |
let pattern = SinglePlaceholderPattern::try_from_str( |
| 21 |
"Hello, {0}!", |
| 22 |
Default::default(), |
| 23 |
) |
| 24 |
.unwrap(); |
| 25 |
|
| 26 |
// Interpolate into the pattern string: |
| 27 |
assert_writeable_eq!(pattern.interpolate(["World"]), "Hello, World!"); |
| 28 |
``` |
| 29 |
|
| 30 |
[`ICU4X`]: ../icu/index.html |
| 31 |
[`FromStr`]: core::str::FromStr |
| 32 |
|
| 33 |
<!-- cargo-rdme end --> |
| 34 |
|
| 35 |
## More Information |
| 36 |
|
| 37 |
For more information on development, authorship, contributing etc. please visit [`ICU4X home page`](https://github.com/unicode-org/icu4x). |