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
impl ExemplarCharacters
sourcepub fn as_borrowed(&self) -> ExemplarCharactersBorrowed<'_>
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
impl ExemplarCharacters
sourcepub fn try_new_main(
locale: &DataLocale,
) -> Result<ExemplarCharactersBorrowed<'static>, DataError>
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.
§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"));
sourcepub fn try_new_main_unstable(
provider: &(impl DataProvider<ExemplarCharactersMainV1Marker> + ?Sized),
locale: &DataLocale,
) -> Result<Self, DataError>
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
].
sourcepub fn try_new_auxiliary(
locale: &DataLocale,
) -> Result<ExemplarCharactersBorrowed<'static>, DataError>
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.
§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"));
sourcepub fn try_new_auxiliary_unstable(
provider: &(impl DataProvider<ExemplarCharactersAuxiliaryV1Marker> + ?Sized),
locale: &DataLocale,
) -> Result<Self, DataError>
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
].
sourcepub fn try_new_punctuation(
locale: &DataLocale,
) -> Result<ExemplarCharactersBorrowed<'static>, DataError>
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.
§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('?'));
sourcepub fn try_new_punctuation_unstable(
provider: &(impl DataProvider<ExemplarCharactersPunctuationV1Marker> + ?Sized),
locale: &DataLocale,
) -> Result<Self, DataError>
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
].
sourcepub fn try_new_numbers(
locale: &DataLocale,
) -> Result<ExemplarCharactersBorrowed<'static>, DataError>
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.
§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('?'));
sourcepub fn try_new_numbers_unstable(
provider: &(impl DataProvider<ExemplarCharactersNumbersV1Marker> + ?Sized),
locale: &DataLocale,
) -> Result<Self, DataError>
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
].
sourcepub fn try_new_index(
locale: &DataLocale,
) -> Result<ExemplarCharactersBorrowed<'static>, DataError>
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.
§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"));
sourcepub fn try_new_index_unstable(
provider: &(impl DataProvider<ExemplarCharactersIndexV1Marker> + ?Sized),
locale: &DataLocale,
) -> Result<Self, DataError>
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
].
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ExemplarCharacters
impl RefUnwindSafe for ExemplarCharacters
impl Send for ExemplarCharacters
impl Sync for ExemplarCharacters
impl Unpin for ExemplarCharacters
impl UnwindSafe for ExemplarCharacters
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
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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