Struct ExemplarCharactersBorrowed

Source
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>

Source

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>

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§

impl ExemplarCharactersBorrowed<'static>

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§

impl ExemplarCharactersBorrowed<'static>

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§

impl ExemplarCharactersBorrowed<'static>

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§

impl ExemplarCharactersBorrowed<'static>

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"));

Methods from Deref<Target = CodePointInversionListAndStringList<'a>>§

Source

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.

Source

pub fn has_strings(&self) -> bool

Return true if this set contains multi-code point strings or the empty string.

Source

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!"));
Source

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));
Source

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
Source

pub fn code_points(&self) -> &CodePointInversionList<'data>

Access the underlying CodePointInversionList.

Source

pub fn strings(&self) -> &VarZeroSlice<str>

Access the contained strings.

Trait Implementations§

Source§

impl<'a> Clone for ExemplarCharactersBorrowed<'a>

Source§

fn clone(&self) -> ExemplarCharactersBorrowed<'a>

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
Source§

impl<'a> Debug for ExemplarCharactersBorrowed<'a>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'a> Deref for ExemplarCharactersBorrowed<'a>

Source§

type Target = CodePointInversionListAndStringList<'a>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &<ExemplarCharactersBorrowed<'a> as Deref>::Target

Dereferences the value.
Source§

impl<'a> Copy for ExemplarCharactersBorrowed<'a>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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 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.
Source§

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