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

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

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

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.