Struct icu_locale::exemplar_chars::ExemplarCharacters

source ·
pub struct ExemplarCharacters { /* private fields */ }
Expand description

A wrapper around UnicodeSet data (characters and strings)

Implementations§

source§

impl ExemplarCharacters

source

pub fn as_borrowed(&self) -> ExemplarCharactersBorrowed<'_>

Construct a borrowed version of this type that can be queried.

This avoids a potential small underlying cost per API call (ex: contains()) by consolidating it up front.

source§

impl ExemplarCharacters

source

pub fn try_new_main( locale: &DataLocale, ) -> Result<ExemplarCharactersBorrowed<'static>, DataError>

Get the “main” set of exemplar characters.

Enabled with the compiled_data Cargo feature.

📚 Help choosing a constructor

§Examples
use icu::locale::locale;
use icu::locale::exemplar_chars::ExemplarCharacters;

let exemplars_main = ExemplarCharacters::try_new_main(&locale!("en").into())
    .expect("locale should be present");

assert!(exemplars_main.contains('a'));
assert!(exemplars_main.contains('z'));
assert!(exemplars_main.contains_str("a"));
assert!(!exemplars_main.contains_str("ä"));
assert!(!exemplars_main.contains_str("ng"));
assert!(!exemplars_main.contains_str("A"));
source

pub fn try_new_main_unstable( provider: &(impl DataProvider<ExemplarCharactersMainV1Marker> + ?Sized), locale: &DataLocale, ) -> Result<Self, DataError>

A version of Self::try_new_main() that uses custom data provided by a [DataProvider].

📚 Help choosing a constructor

source

pub fn try_new_auxiliary( locale: &DataLocale, ) -> Result<ExemplarCharactersBorrowed<'static>, DataError>

Get the “auxiliary” set of exemplar characters.

Enabled with the compiled_data Cargo feature.

📚 Help choosing a constructor

§Examples
use icu::locale::locale;
use icu::locale::exemplar_chars::ExemplarCharacters;

let exemplars_auxiliary =
    ExemplarCharacters::try_new_auxiliary(&locale!("en").into())
    .expect("locale should be present");

assert!(!exemplars_auxiliary.contains('a'));
assert!(!exemplars_auxiliary.contains('z'));
assert!(!exemplars_auxiliary.contains_str("a"));
assert!(exemplars_auxiliary.contains_str("ä"));
assert!(!exemplars_auxiliary.contains_str("ng"));
assert!(!exemplars_auxiliary.contains_str("A"));
source

pub fn try_new_auxiliary_unstable( provider: &(impl DataProvider<ExemplarCharactersAuxiliaryV1Marker> + ?Sized), locale: &DataLocale, ) -> Result<Self, DataError>

A version of Self::try_new_auxiliary() that uses custom data provided by a [DataProvider].

📚 Help choosing a constructor

source

pub fn try_new_punctuation( locale: &DataLocale, ) -> Result<ExemplarCharactersBorrowed<'static>, DataError>

Get the “punctuation” set of exemplar characters.

Enabled with the compiled_data Cargo feature.

📚 Help choosing a constructor

§Examples
use icu::locale::locale;
use icu::locale::exemplar_chars::ExemplarCharacters;

let exemplars_punctuation =
    ExemplarCharacters::try_new_punctuation(&locale!("en").into())
    .expect("locale should be present");

assert!(!exemplars_punctuation.contains('0'));
assert!(!exemplars_punctuation.contains('9'));
assert!(!exemplars_punctuation.contains('%'));
assert!(exemplars_punctuation.contains(','));
assert!(exemplars_punctuation.contains('.'));
assert!(exemplars_punctuation.contains('!'));
assert!(exemplars_punctuation.contains('?'));
source

pub fn try_new_punctuation_unstable( provider: &(impl DataProvider<ExemplarCharactersPunctuationV1Marker> + ?Sized), locale: &DataLocale, ) -> Result<Self, DataError>

A version of Self::try_new_punctuation() that uses custom data provided by a [DataProvider].

📚 Help choosing a constructor

source

pub fn try_new_numbers( locale: &DataLocale, ) -> Result<ExemplarCharactersBorrowed<'static>, DataError>

Get the “numbers” set of exemplar characters.

Enabled with the compiled_data Cargo feature.

📚 Help choosing a constructor

§Examples
use icu::locale::locale;
use icu::locale::exemplar_chars::ExemplarCharacters;

let exemplars_numbers =
    ExemplarCharacters::try_new_numbers(&locale!("en").into())
    .expect("locale should be present");

assert!(exemplars_numbers.contains('0'));
assert!(exemplars_numbers.contains('9'));
assert!(exemplars_numbers.contains('%'));
assert!(exemplars_numbers.contains(','));
assert!(exemplars_numbers.contains('.'));
assert!(!exemplars_numbers.contains('!'));
assert!(!exemplars_numbers.contains('?'));
source

pub fn try_new_numbers_unstable( provider: &(impl DataProvider<ExemplarCharactersNumbersV1Marker> + ?Sized), locale: &DataLocale, ) -> Result<Self, DataError>

A version of Self::try_new_numbers() that uses custom data provided by a [DataProvider].

📚 Help choosing a constructor

source

pub fn try_new_index( locale: &DataLocale, ) -> Result<ExemplarCharactersBorrowed<'static>, DataError>

Get the “index” set of exemplar characters.

Enabled with the compiled_data Cargo feature.

📚 Help choosing a constructor

§Examples
use icu::locale::locale;
use icu::locale::exemplar_chars::ExemplarCharacters;

let exemplars_index =
    ExemplarCharacters::try_new_index(&locale!("en").into())
    .expect("locale should be present");

assert!(!exemplars_index.contains('a'));
assert!(!exemplars_index.contains('z'));
assert!(!exemplars_index.contains_str("a"));
assert!(!exemplars_index.contains_str("ä"));
assert!(!exemplars_index.contains_str("ng"));
assert!(exemplars_index.contains_str("A"));
source

pub fn try_new_index_unstable( provider: &(impl DataProvider<ExemplarCharactersIndexV1Marker> + ?Sized), locale: &DataLocale, ) -> Result<Self, DataError>

A version of Self::try_new_index() that uses custom data provided by a [DataProvider].

📚 Help choosing a constructor

Trait Implementations§

source§

impl Debug for ExemplarCharacters

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

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

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
source§

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

source§

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

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
§

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

§

impl<T> MaybeSendSync for T
where T: Send + Sync,