Skip to main content

SinglePlaceholderPattern

Type Alias SinglePlaceholderPattern 

Source
pub type SinglePlaceholderPattern = Pattern<SinglePlaceholder>;
Expand description

§Examples

use core::str::FromStr;
use icu_pattern::SinglePlaceholderPattern;
use writeable::assert_writeable_eq;

// Create a pattern from the string syntax:
let pattern = SinglePlaceholderPattern::try_from_str(
    "Hello, {0}!",
    Default::default(),
)
.unwrap();

// Interpolate some values into the pattern:
assert_writeable_eq!(pattern.interpolate(["Alice"]), "Hello, Alice!");

Aliased Type§

#[repr(transparent)]
pub struct SinglePlaceholderPattern { pub store: str, /* private fields */ }

Fields§

§store: str

The encoded storage

Implementations§

Source§

impl SinglePlaceholderPattern

Source

pub const PASS_THROUGH: &'static SinglePlaceholderPattern

An instance of SinglePlaceholderPattern that has a single placeholder and adds no prefix or suffix.

§Examples
use icu_pattern::SinglePlaceholderPattern;
use writeable::assert_writeable_eq;

assert_eq!(
    SinglePlaceholderPattern::PASS_THROUGH,
    &*SinglePlaceholderPattern::try_from_str("{0}", Default::default())
        .unwrap()
);

assert_writeable_eq!(
    SinglePlaceholderPattern::PASS_THROUGH.interpolate(["hello, world!"]),
    "hello, world!"
);