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

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

Implementations

Get the value this map has associated with code point ch

Example
use icu::properties::{maps, GeneralCategory};
use icu_collections::codepointtrie::CodePointTrie;

let data =
    maps::load_general_category(&icu_testdata::unstable())
        .expect("The data should be valid");
let gc = data.as_borrowed();

assert_eq!(gc.get('木'), GeneralCategory::OtherLetter);  // U+6728
assert_eq!(gc.get('🎃'), GeneralCategory::OtherSymbol);  // U+1F383 JACK-O-LANTERN

Get the value this map has associated with code point ch

Example
use icu::properties::{maps, GeneralCategory};
use icu_collections::codepointtrie::CodePointTrie;

let data =
    maps::load_general_category(&icu_testdata::unstable())
        .expect("The data should be valid");
let gc = data.as_borrowed();

assert_eq!(gc.get32(0x6728), GeneralCategory::OtherLetter);  // U+6728 (木)
assert_eq!(gc.get32(0x1F383), GeneralCategory::OtherSymbol);  // U+1F383 JACK-O-LANTERN

Get a CodePointSetData for all elements corresponding to a particular value

Example
use icu::properties::{maps, GeneralCategory};
use icu_collections::codepointtrie::CodePointTrie;

let data = maps::load_general_category(&icu_testdata::unstable())
    .expect("The data should be valid");
let gc = data.as_borrowed();

let other_letter_set_data =
    gc.get_set_for_value(GeneralCategory::OtherLetter);
let other_letter_set = other_letter_set_data.as_borrowed();

assert!(other_letter_set.contains('木')); // U+6728
assert!(!other_letter_set.contains('🎃')); // U+1F383 JACK-O-LANTERN

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

Examples
use core::ops::RangeInclusive;
use icu::properties::maps::CodePointMapData;
use icu_collections::codepointtrie::planes;
use icu_collections::codepointtrie::CodePointMapRange;

let planes_trie = planes::get_planes_trie();
let cp_map_data = CodePointMapData::from_code_point_trie(planes_trie);
let cp_map = cp_map_data.as_borrowed();

let mut ranges = cp_map.iter_ranges();

for plane in 0..=16 {
    let exp_start = plane * 0x1_0000;
    let exp_end = exp_start + 0xffff;
    assert_eq!(
        ranges.next(),
        Some(CodePointMapRange {
            range: RangeInclusive::new(exp_start, exp_end),
            value: plane as u8
        })
    );
}

// Hitting the end of the iterator returns `None`, as will subsequent
// calls to .next().
assert_eq!(ranges.next(), None);
assert_eq!(ranges.next(), None);

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.