Struct CodePointMapDataBorrowed

struct CodePointMapDataBorrowed<'a, T: TrieValue> { ... }

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

Implementations

impl<'a> CodePointMapDataBorrowed<'a, GeneralCategory>

fn iter_ranges_for_group(self: Self, group: GeneralCategoryGroup) -> impl Iterator<Item = RangeInclusive<u32>> + 'a

Yields an Iterator returning ranges of consecutive code points that have a General_Category value belonging to the specified GeneralCategoryGroup

Examples

use icu::properties::props::{GeneralCategory, GeneralCategoryGroup};
use icu::properties::CodePointMapData;

let gc = CodePointMapData::<GeneralCategory>::new();
let mut ranges = gc.iter_ranges_for_group(GeneralCategoryGroup::Letter);
assert_eq!(ranges.next().unwrap(), 'A' as u32..='Z' as u32);
assert_eq!(ranges.next().unwrap(), 'a' as u32..='z' as u32);
assert_eq!(ranges.next().unwrap(), 'ª' as u32..='ª' as u32);
assert_eq!(ranges.next().unwrap(), 'µ' as u32..='µ' as u32);
assert_eq!(ranges.next().unwrap(), 'º' as u32..='º' as u32);
assert_eq!(ranges.next().unwrap(), 'À' as u32..='Ö' as u32);
assert_eq!(ranges.next().unwrap(), 'Ø' as u32..='ö' as u32);

impl<'a, T: TrieValue> CodePointMapDataBorrowed<'a, T>

fn get(self: Self, ch: char) -> T

Get the value this map has associated with code point ch

Example

use icu::properties::CodePointMapData;
use icu::properties::props::GeneralCategory;

let gc = CodePointMapData::<GeneralCategory>::new();

assert_eq!(gc.get(''), GeneralCategory::OtherLetter);  // U+6728
assert_eq!(gc.get('🎃'), GeneralCategory::OtherSymbol);  // U+1F383 JACK-O-LANTERN
fn get32(self: Self, ch: u32) -> T

See Self::get.

fn iter_ranges(self: Self) -> impl Iterator<Item = CodePointMapRange<T>> + 'a

Yields an Iterator returning ranges of consecutive code points that share the same value in the CodePointMapData.

Examples

use icu::properties::props::GeneralCategory;
use icu::properties::CodePointMapData;

let gc = CodePointMapData::<GeneralCategory>::new();
let mut ranges = gc.iter_ranges();
let next = ranges.next().unwrap();
assert_eq!(next.range, 0..=31);
assert_eq!(next.value, GeneralCategory::Control);
let next = ranges.next().unwrap();
assert_eq!(next.range, 32..=32);
assert_eq!(next.value, GeneralCategory::SpaceSeparator);
fn iter_ranges_for_value(self: Self, val: T) -> impl Iterator<Item = RangeInclusive<u32>> + 'a

Yields an Iterator returning ranges of consecutive code points that share the same value v in the CodePointMapData.

Examples

use icu::properties::props::GeneralCategory;
use icu::properties::CodePointMapData;

let gc = CodePointMapData::<GeneralCategory>::new();
let mut ranges = gc.iter_ranges_for_value(GeneralCategory::UppercaseLetter);
assert_eq!(ranges.next().unwrap(), 'A' as u32..='Z' as u32);
assert_eq!(ranges.next().unwrap(), 'À' as u32..='Ö' as u32);
assert_eq!(ranges.next().unwrap(), 'Ø' as u32..='Þ' as u32);
fn iter_ranges_for_value_complemented(self: Self, val: T) -> impl Iterator<Item = RangeInclusive<u32>> + 'a

Yields an Iterator returning ranges of consecutive code points that do not have the value v in the CodePointMapData.

impl<T: TrieValue> CodePointMapDataBorrowed<'static, T>

const fn new() -> Self
where
    T: EnumeratedProperty

Creates a new CodePointMapDataBorrowed for a EnumeratedProperty.

See the documentation on EnumeratedProperty implementations for details.

Enabled with the compiled_data Cargo feature.

📚 Help choosing a constructor

const fn static_to_owned(self: Self) -> CodePointMapData<T>

Cheaply converts a [CodePointMapDataBorrowed<'static>] into a CodePointMapData.

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

impl<'a, T> Freeze for CodePointMapDataBorrowed<'a, T>

impl<'a, T> RefUnwindSafe for CodePointMapDataBorrowed<'a, T>

impl<'a, T> Send for CodePointMapDataBorrowed<'a, T>

impl<'a, T> Sync for CodePointMapDataBorrowed<'a, T>

impl<'a, T> Unpin for CodePointMapDataBorrowed<'a, T>

impl<'a, T> UnsafeUnpin for CodePointMapDataBorrowed<'a, T>

impl<'a, T> UnwindSafe for CodePointMapDataBorrowed<'a, T>

impl<'a, T: $crate::clone::Clone + TrieValue> Clone for CodePointMapDataBorrowed<'a, T>

fn clone(self: &Self) -> CodePointMapDataBorrowed<'a, T>

impl<'a, T: $crate::fmt::Debug + TrieValue> Debug for CodePointMapDataBorrowed<'a, T>

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

impl<'a, T: $crate::marker::Copy + TrieValue> Copy for CodePointMapDataBorrowed<'a, T>

impl<T> Any for CodePointMapDataBorrowed<'a, T>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for CodePointMapDataBorrowed<'a, T>

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

impl<T> BorrowMut for CodePointMapDataBorrowed<'a, T>

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

impl<T> CloneToUninit for CodePointMapDataBorrowed<'a, T>

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

impl<T> ErasedDestructor for CodePointMapDataBorrowed<'a, T>

impl<T> From for CodePointMapDataBorrowed<'a, T>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for CodePointMapDataBorrowed<'a, T>

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

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

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 CodePointMapDataBorrowed<'a, T>

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

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

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

impl<T: EnumeratedProperty> Default for CodePointMapDataBorrowed<'static, T>

fn default() -> Self