CodePointMapDataBorrowed

Struct CodePointMapDataBorrowed 

Source
pub struct CodePointMapDataBorrowed<'a, T: TrieValue> { /* private fields */ }
Expand description

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

Implementations§

Source§

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

Source

pub fn get(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
Source

pub fn get32(self, ch: u32) -> T

See Self::get.

Source

pub fn iter_ranges(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);
Source

pub fn iter_ranges_for_value( 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);
Source

pub fn iter_ranges_for_value_complemented( 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.

Source§

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

Source

pub const fn new() -> Self

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

Source

pub const fn static_to_owned(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.

Source§

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

Source

pub fn iter_ranges_for_group( 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);

Trait Implementations§

Source§

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

Source§

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

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

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

Source§

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

Formats the value using the given formatter. Read more
Source§

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

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

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

Auto Trait Implementations§

§

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

§

impl<'a, T> RefUnwindSafe for CodePointMapDataBorrowed<'a, T>
where T: RefUnwindSafe, <T as AsULE>::ULE: RefUnwindSafe,

§

impl<'a, T> Send for CodePointMapDataBorrowed<'a, T>
where T: Sync, <T as AsULE>::ULE: Sync,

§

impl<'a, T> Sync for CodePointMapDataBorrowed<'a, T>
where T: Sync, <T as AsULE>::ULE: Sync,

§

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

§

impl<'a, T> UnwindSafe for CodePointMapDataBorrowed<'a, T>
where T: RefUnwindSafe, <T as AsULE>::ULE: RefUnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

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

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 8 bytes