pub struct ExemplarCharactersBorrowed<'a> { /* private fields */ }
Expand description
A borrowed wrapper around code point set data, returned by
ExemplarCharacters::as_borrowed()
. More efficient to query.
Implementations§
Source§impl ExemplarCharactersBorrowed<'static>
impl ExemplarCharactersBorrowed<'static>
Sourcepub const fn static_to_owned(self) -> ExemplarCharacters
pub const fn static_to_owned(self) -> ExemplarCharacters
Cheaply converts a [ExemplarCharactersBorrowed<'static>
] into a ExemplarCharacters
.
Note: Due to branching and indirection, using ExemplarCharacters
might inhibit some
compile-time optimizations that are possible with ExemplarCharactersBorrowed
.
Source§impl ExemplarCharactersBorrowed<'static>
impl ExemplarCharactersBorrowed<'static>
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"));
Source§impl ExemplarCharactersBorrowed<'static>
impl ExemplarCharactersBorrowed<'static>
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"));
Source§impl ExemplarCharactersBorrowed<'static>
impl ExemplarCharactersBorrowed<'static>
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('?'));
Source§impl ExemplarCharactersBorrowed<'static>
impl ExemplarCharactersBorrowed<'static>
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('?'));
Source§impl ExemplarCharactersBorrowed<'static>
impl ExemplarCharactersBorrowed<'static>
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"));
Methods from Deref<Target = CodePointInversionListAndStringList<'a>>§
Sourcepub fn size(&self) -> usize
pub fn size(&self) -> usize
Returns the number of elements in this set (its cardinality). Note than the elements of a set may include both individual codepoints and strings.
Sourcepub fn has_strings(&self) -> bool
pub fn has_strings(&self) -> bool
Return true if this set contains multi-code point strings or the empty string.
Sourcepub fn contains_str(&self, s: &str) -> bool
pub fn contains_str(&self, s: &str) -> bool
§Examples
use icu::collections::codepointinvlist::CodePointInversionList;
use icu::collections::codepointinvliststringlist::CodePointInversionListAndStringList;
use zerovec::VarZeroVec;
let cp_slice = &[0, 0x1_0000, 0x10_FFFF, 0x11_0000];
let cp_list =
CodePointInversionList::try_from_u32_inversion_list_slice(cp_slice).unwrap();
let str_slice = &["", "bmp_max", "unicode_max", "zero"];
let str_list = VarZeroVec::<str>::from(str_slice);
let cpilsl = CodePointInversionListAndStringList::try_from(cp_list, str_list).unwrap();
assert!(cpilsl.contains_str("bmp_max"));
assert!(cpilsl.contains_str(""));
assert!(cpilsl.contains_str("A"));
assert!(cpilsl.contains_str("ቔ")); // U+1254 ETHIOPIC SYLLABLE QHEE
assert!(!cpilsl.contains_str("bazinga!"));
Sourcepub fn contains32(&self, cp: u32) -> bool
pub fn contains32(&self, cp: u32) -> bool
§Examples
use icu::collections::codepointinvlist::CodePointInversionList;
use icu::collections::codepointinvliststringlist::CodePointInversionListAndStringList;
use zerovec::VarZeroVec;
let cp_slice = &[0, 0x80, 0xFFFF, 0x1_0000, 0x10_FFFF, 0x11_0000];
let cp_list =
CodePointInversionList::try_from_u32_inversion_list_slice(cp_slice).unwrap();
let str_slice = &["", "ascii_max", "bmp_max", "unicode_max", "zero"];
let str_list = VarZeroVec::<str>::from(str_slice);
let cpilsl = CodePointInversionListAndStringList::try_from(cp_list, str_list).unwrap();
assert!(cpilsl.contains32(0));
assert!(cpilsl.contains32(0x0042));
assert!(!cpilsl.contains32(0x0080));
Sourcepub fn contains(&self, ch: char) -> bool
pub fn contains(&self, ch: char) -> bool
§Examples
use icu::collections::codepointinvlist::CodePointInversionList;
use icu::collections::codepointinvliststringlist::CodePointInversionListAndStringList;
use zerovec::VarZeroVec;
let cp_slice = &[0, 0x1_0000, 0x10_FFFF, 0x11_0000];
let cp_list =
CodePointInversionList::try_from_u32_inversion_list_slice(cp_slice).unwrap();
let str_slice = &["", "bmp_max", "unicode_max", "zero"];
let str_list = VarZeroVec::<str>::from(str_slice);
let cpilsl = CodePointInversionListAndStringList::try_from(cp_list, str_list).unwrap();
assert!(cpilsl.contains('A'));
assert!(cpilsl.contains('ቔ')); // U+1254 ETHIOPIC SYLLABLE QHEE
assert!(!cpilsl.contains('\u{1_0000}'));
assert!(!cpilsl.contains('🨫')); // U+1FA2B NEUTRAL CHESS TURNED QUEEN
Sourcepub fn code_points(&self) -> &CodePointInversionList<'data>
pub fn code_points(&self) -> &CodePointInversionList<'data>
Access the underlying CodePointInversionList
.
Sourcepub fn strings(&self) -> &VarZeroSlice<str>
pub fn strings(&self) -> &VarZeroSlice<str>
Access the contained strings.
Trait Implementations§
Source§impl<'a> Clone for ExemplarCharactersBorrowed<'a>
impl<'a> Clone for ExemplarCharactersBorrowed<'a>
Source§fn clone(&self) -> ExemplarCharactersBorrowed<'a>
fn clone(&self) -> ExemplarCharactersBorrowed<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<'a> Debug for ExemplarCharactersBorrowed<'a>
impl<'a> Debug for ExemplarCharactersBorrowed<'a>
Source§impl<'a> Deref for ExemplarCharactersBorrowed<'a>
impl<'a> Deref for ExemplarCharactersBorrowed<'a>
Source§type Target = CodePointInversionListAndStringList<'a>
type Target = CodePointInversionListAndStringList<'a>
impl<'a> Copy for ExemplarCharactersBorrowed<'a>
Auto Trait Implementations§
impl<'a> Freeze for ExemplarCharactersBorrowed<'a>
impl<'a> RefUnwindSafe for ExemplarCharactersBorrowed<'a>
impl<'a> Send for ExemplarCharactersBorrowed<'a>
impl<'a> Sync for ExemplarCharactersBorrowed<'a>
impl<'a> Unpin for ExemplarCharactersBorrowed<'a>
impl<'a> UnwindSafe for ExemplarCharactersBorrowed<'a>
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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