pub struct CanonicalComposition { /* private fields */ }
Expand description
The raw canonical composition operation.
Callers should generally use ComposingNormalizer
instead of this API.
However, this API is provided for callers such as HarfBuzz that specifically
want access to the raw canonical composition operation e.g. for use in a
glyph-availability-guided custom normalizer.
Implementations§
Source§impl CanonicalComposition
impl CanonicalComposition
Sourcepub fn compose(&self, starter: char, second: char) -> Option<char>
pub fn compose(&self, starter: char, second: char) -> Option<char>
Performs canonical composition (including Hangul) on a pair of
characters or returns None
if these characters don’t compose.
Composition exclusions are taken into account.
§Examples
let comp = icu::normalizer::properties::CanonicalComposition::new();
assert_eq!(comp.compose('a', 'b'), None); // Just two non-composing starters
assert_eq!(comp.compose('a', '\u{0308}'), Some('ä'));
assert_eq!(comp.compose('ẹ', '\u{0302}'), Some('ệ'));
assert_eq!(comp.compose('𝅗', '𝅥'), None); // Composition exclusion
assert_eq!(comp.compose('ে', 'া'), Some('ো')); // Second is starter
assert_eq!(comp.compose('ᄀ', 'ᅡ'), Some('가')); // Hangul LV
assert_eq!(comp.compose('가', 'ᆨ'), Some('각')); // Hangul LVT
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Constructs a new CanonicalComposition
using compiled data.
✨ Enabled with the compiled_data
Cargo feature.
Sourcepub fn try_new_with_any_provider(
provider: &(impl AnyProvider + ?Sized),
) -> Result<Self, NormalizerError>
pub fn try_new_with_any_provider( provider: &(impl AnyProvider + ?Sized), ) -> Result<Self, NormalizerError>
A version of [Self :: new
] that uses custom data provided by an AnyProvider
.
Sourcepub fn try_new_unstable<D>(provider: &D) -> Result<Self, NormalizerError>
pub fn try_new_unstable<D>(provider: &D) -> Result<Self, NormalizerError>
A version of Self::new
that uses custom data provided by a DataProvider
.
⚠️ The bounds on provider may change over time, including in SemVer minor releases.
Trait Implementations§
Source§impl Debug for CanonicalComposition
impl Debug for CanonicalComposition
Auto Trait Implementations§
impl Freeze for CanonicalComposition
impl RefUnwindSafe for CanonicalComposition
impl !Send for CanonicalComposition
impl !Sync for CanonicalComposition
impl Unpin for CanonicalComposition
impl UnwindSafe for CanonicalComposition
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more