Struct icu::locale::exemplar_chars::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>
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
.
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>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
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>
The resulting type after dereferencing.
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
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)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>
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 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>
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