Struct CodePointSetDataBorrowed

struct CodePointSetDataBorrowed<'a> { ... }

A borrowed wrapper around code point set data, returned by [CodePointSetData::as_borrowed()]. More efficient to query.

Implementations

impl CodePointSetDataBorrowed<'static>

const fn new<P: BinaryProperty>() -> Self

Creates a new CodePointSetData for a BinaryProperty.

Enabled with the compiled_data Cargo feature.

📚 Help choosing a constructor

const fn static_to_owned(self: Self) -> CodePointSetData

Cheaply converts a [CodePointSetDataBorrowed<'static>] into a CodePointSetData.

Note: Due to branching and indirection, using CodePointSetData might inhibit some compile-time optimizations that are possible with CodePointSetDataBorrowed.

impl<'a> CodePointSetDataBorrowed<'a>

fn contains(self: Self, ch: char) -> bool

Check if the set contains a character

use icu::properties::CodePointSetData;
use icu::properties::props::Alphabetic;

let alphabetic = CodePointSetData::new::<Alphabetic>();

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
fn contains32(self: Self, ch: u32) -> bool

See Self::contains.

fn iter_ranges(self: 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::props::Alphabetic;
use icu::properties::CodePointSetData;

let alphabetic = CodePointSetData::new::<Alphabetic>();
let mut ranges = alphabetic.iter_ranges();

assert_eq!(Some(0x0041..=0x005A), ranges.next()); // 'A'..'Z'
assert_eq!(Some(0x0061..=0x007A), ranges.next()); // 'a'..'z'
fn iter_ranges_complemented(self: Self) -> impl Iterator<Item = RangeInclusive<u32>> + 'a

not 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::props::Alphabetic;
use icu::properties::CodePointSetData;

let alphabetic = CodePointSetData::new::<Alphabetic>();
let mut ranges = alphabetic.iter_ranges();

assert_eq!(Some(0x0041..=0x005A), ranges.next()); // 'A'..'Z'
assert_eq!(Some(0x0061..=0x007A), ranges.next()); // 'a'..'z'

impl<'a> Clone for CodePointSetDataBorrowed<'a>

fn clone(self: &Self) -> CodePointSetDataBorrowed<'a>

impl<'a> Copy for CodePointSetDataBorrowed<'a>

impl<'a> Debug for CodePointSetDataBorrowed<'a>

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

impl<'a> Freeze for CodePointSetDataBorrowed<'a>

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> UnsafeUnpin for CodePointSetDataBorrowed<'a>

impl<'a> UnwindSafe for CodePointSetDataBorrowed<'a>

impl<T> Any for CodePointSetDataBorrowed<'a>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for CodePointSetDataBorrowed<'a>

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for CodePointSetDataBorrowed<'a>

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> CloneToUninit for CodePointSetDataBorrowed<'a>

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

impl<T> ErasedDestructor for CodePointSetDataBorrowed<'a>

impl<T> From for CodePointSetDataBorrowed<'a>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for CodePointSetDataBorrowed<'a>

fn to_owned(self: &Self) -> T
fn clone_into(self: &Self, target: &mut T)

impl<T, U> Into for CodePointSetDataBorrowed<'a>

fn into(self: Self) -> U

Calls U::from(self).

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

impl<T, U> TryFrom for CodePointSetDataBorrowed<'a>

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for CodePointSetDataBorrowed<'a>

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>