pub struct CaseMapping { /* private fields */ }
Expand description

A struct with the ability to convert characters and strings to uppercase or lowercase, or fold them to a normalized form for case-insensitive comparison.

🚧 This code is experimental; it may change at any time, in breaking or non-breaking ways, including in SemVer minor releases. It can be enabled with the "experimental" Cargo feature of the icu meta-crate. Use with caution. #2535

Implementations§

source§

impl CaseMapping

source

pub fn try_new<P>(provider: &P) -> Result<CaseMapping, DataError>where P: DataProvider<CaseMappingV1Marker> + ?Sized,

A constructor which takes a DataProvider and creates a CaseMapping.

TODO before stabilitzation: make this return a crate-scoped error.

source

pub fn try_new_with_locale<P>( provider: &P, locale: &Locale ) -> Result<CaseMapping, DataError>where P: DataProvider<CaseMappingV1Marker> + ?Sized,

A constructor which takes a DataProvider and creates a CaseMapping for the given locale.

TODO before stabilitzation: make this return a crate-scoped error.

source

pub fn try_from_icu( trie_header: CodePointTrieHeader, trie_index: &[u16], trie_data: &[u16], exceptions: &[u16], unfold: &[u16] ) -> Result<Self, Error>

Creates a new CaseMapping using data exported by the icuexportdata tool in ICU4C. Validates that the data is consistent.

source

pub fn to_lowercase(&self, c: char) -> char

Returns the lowercase mapping of the given char. This function only implements simple and common mappings. Full mappings, which can map one char to a string, are not included. For full mappings, use CaseMapping::to_full_lowercase.

source

pub fn to_uppercase(&self, c: char) -> char

Returns the uppercase mapping of the given char. This function only implements simple and common mappings. Full mappings, which can map one char to a string, are not included. For full mappings, use CaseMapping::to_full_uppercase.

source

pub fn to_titlecase(&self, c: char) -> char

Returns the titlecase mapping of the given char. This function only implements simple and common mappings. Full mappings, which can map one char to a string, are not included.

source

pub fn fold(&self, c: char) -> char

Returns the simple case folding mapping of the given char. For full mappings, use CaseMapping::full_fold.

source

pub fn fold_turkic(&self, c: char) -> char

Returns the simple case folding mapping of the given char, using Turkic (T) mappings for dotted/dotless i. This function does not fold i and I to the same character. Instead, I will fold to ı, and İ will fold to i. Otherwise, this is the same as CaseMapping::fold().

source

pub fn to_full_lowercase(&self, src: &str) -> String

Returns the full lowercase mapping of the given string. This function is context and locale sensitive.

source

pub fn to_full_uppercase(&self, src: &str) -> String

Returns the full uppercase mapping of the given string. This function is context and locale sensitive.

source

pub fn full_fold(&self, src: &str) -> String

Case-folds the characters in the given string. This function is locale-independent and context-insensitive.

source

pub fn full_fold_turkic(&self, src: &str) -> String

Case-folds the characters in the given string, using Turkic (T) mappings for dotted/dotless I. This function is locale-independent and context-insensitive.

Trait Implementations§

source§

impl Clone for CaseMapping

source§

fn clone(&self) -> CaseMapping

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> ErasedDestructor for Twhere T: 'static,

source§

impl<T> MaybeSendSync for T