forked from unicode-org/icu4x
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes to icu_pattern and DurationFormatter formatToParts
- Loading branch information
Showing
9 changed files
with
94 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// This file is part of ICU4X. For terms of use, please see the file | ||
// called LICENSE at the top level of the ICU4X source tree | ||
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). | ||
|
||
//! Parts of a formatted pattern. | ||
//! | ||
//! # Examples | ||
//! | ||
//! Interpolating a [`SinglePlaceholder`] pattern with parts: | ||
//! | ||
//! ``` | ||
//! use core::str::FromStr; | ||
//! use icu_pattern::Pattern; | ||
//! use icu_pattern::SinglePlaceholder; | ||
//! use writeable::assert_writeable_parts_eq; | ||
//! | ||
//! let pattern = Pattern::<SinglePlaceholder>::try_from_str( | ||
//! "Hello, {0}!", | ||
//! Default::default(), | ||
//! ) | ||
//! .unwrap(); | ||
//! | ||
//! assert_writeable_parts_eq!( | ||
//! pattern.interpolate(["Alice"]), | ||
//! "Hello, Alice!", | ||
//! [ | ||
//! (0, 7, icu_pattern::parts::LITERAL), | ||
//! (7, 12, icu_pattern::parts::PLACEHOLDER), | ||
//! (12, 13, icu_pattern::parts::LITERAL), | ||
//! ] | ||
//! ); | ||
//! ``` | ||
//! | ||
//! [`SinglePlaceholder`]: crate::SinglePlaceholder | ||
//! [`DoublePlaceholder`]: crate::DoublePlaceholder | ||
//! [`MultiNamedPlaceholder`]: crate::MultiNamedPlaceholder | ||
//! [`LITERAL`]: crate::parts::LITERAL | ||
//! [`PLACEHOLDER`]: crate::parts::PLACEHOLDER | ||
use writeable::Part; | ||
|
||
/// Default annotation for the literal portion of a pattern. | ||
/// | ||
/// For more information, see [`PlaceholderValueProvider`]. For an example, see [`Pattern`]. | ||
/// | ||
/// [`Pattern`]: crate::Pattern | ||
pub const LITERAL: Part = Part { | ||
category: "pattern", | ||
value: "literal", | ||
}; | ||
|
||
/// Default annotation for the placeholder portion of a pattern. | ||
/// | ||
/// For more information, see [`PlaceholderValueProvider`]. For an example, see [`Pattern`]. | ||
/// | ||
/// [`Pattern`]: crate::Pattern | ||
pub const PLACEHOLDER: Part = Part { | ||
category: "pattern", | ||
value: "placeholder", | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters