Struct icu::properties::sets::CodePointSetDataBorrowed
source · [−]pub struct CodePointSetDataBorrowed<'a> { /* private fields */ }
Expand description
A borrowed wrapper around code point set data, returned by
CodePointSetData::as_borrowed()
. More efficient to query.
Implementations
sourceimpl<'a> CodePointSetDataBorrowed<'a>
impl<'a> CodePointSetDataBorrowed<'a>
sourcepub fn contains(self, ch: char) -> bool
pub fn contains(self, ch: char) -> bool
Check if the set contains a character
use icu_properties::sets;
let data =
sets::load_alphabetic(&icu_testdata::unstable())
.expect("The data should be valid");
let alphabetic = data.as_borrowed();
assert!(!alphabetic.contains('3'));
assert!(!alphabetic.contains('੩')); // U+0A69 GURMUKHI DIGIT THREE
assert!(alphabetic.contains('A'));
assert!(alphabetic.contains('Ä')); // U+00C4 LATIN CAPITAL LETTER A WITH DIAERESIS
sourcepub fn contains32(self, ch: u32) -> bool
pub fn contains32(self, ch: u32) -> bool
Check if the set contains a character as a UTF32 code unit
use icu_properties::sets;
let data =
sets::load_alphabetic(&icu_testdata::unstable())
.expect("The data should be valid");
let alphabetic = data.as_borrowed();
assert!(!alphabetic.contains32(0x0A69)); // U+0A69 GURMUKHI DIGIT THREE
assert!(alphabetic.contains32(0x00C4)); // U+00C4 LATIN CAPITAL LETTER A WITH DIAERESIS
sourcepub fn iter_ranges(self) -> impl Iterator<Item = RangeInclusive<u32>> + 'a
pub fn iter_ranges(self) -> impl Iterator<Item = RangeInclusive<u32>> + 'a
included in the CodePointSetData
Ranges are returned as RangeInclusive
, which is inclusive of its
end
bound value. An end-inclusive behavior matches the ICU4C/J
behavior of ranges, ex: UnicodeSet::contains(UChar32 start, UChar32 end)
.
Example
use icu_properties::sets;
let data = sets::load_alphabetic(&icu_testdata::unstable())
.expect("The data should be valid");
let alphabetic = data.as_borrowed();
let mut ranges = alphabetic.iter_ranges();
assert_eq!(Some(0x0041..=0x005A), ranges.next()); // 'A'..'Z'
assert_eq!(Some(0x0061..=0x007A), ranges.next()); // 'a'..'z'
Trait Implementations
sourceimpl<'a> Clone for CodePointSetDataBorrowed<'a>
impl<'a> Clone for CodePointSetDataBorrowed<'a>
sourcefn clone(&self) -> CodePointSetDataBorrowed<'a>
fn clone(&self) -> CodePointSetDataBorrowed<'a>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl<'a> Copy for CodePointSetDataBorrowed<'a>
Auto Trait Implementations
impl<'a> RefUnwindSafe for CodePointSetDataBorrowed<'a>
impl<'a> Send for CodePointSetDataBorrowed<'a>
impl<'a> Sync for CodePointSetDataBorrowed<'a>
impl<'a> Unpin for CodePointSetDataBorrowed<'a>
impl<'a> UnwindSafe for CodePointSetDataBorrowed<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more