Struct CodePointTrie
struct CodePointTrie<'trie, T: TrieValue> { ... }
This struct represents a de-serialized CodePointTrie that was exported from
ICU binary data.
For more information:
Implementations
impl<'trie, T: TrieValue> CodePointTrie<'trie, T>
fn try_new(header: CodePointTrieHeader, index: ZeroVec<'trie, u16>, data: ZeroVec<'trie, T>) -> Result<CodePointTrie<'trie, T>, Error>Returns a new
CodePointTriebacked by borrowed data for theindexarray anddataarray, whose data values have widthW.fn get32(self: &Self, code_point: u32) -> TReturns the value that is associated with
code_pointin thisCodePointTrie.Examples
use planes; let trie = get_planes_trie; assert_eq!; // 'A' as u32 assert_eq!; // 'Ꮰ' as u32 assert_eq!; // '𐁄' as u32fn get(self: &Self, c: char) -> TReturns the value that is associated with
charin thisCodePointTrie.Examples
use planes; let trie = get_planes_trie; assert_eq!; // 'A' as u32 assert_eq!; // 'Ꮰ' as u32 assert_eq!; // '𐁄' as u32fn get32_ule(self: &Self, code_point: u32) -> Option<&<T as >::ULE>Returns a reference to the ULE of the value that is associated with
code_pointin thisCodePointTrie.Examples
use planes; let trie = get_planes_trie; assert_eq!; // 'A' as u32 assert_eq!; // 'Ꮰ' as u32 assert_eq!; // '𐁄' as u32fn get_range(self: &Self, start: u32) -> Option<CodePointMapRange<T>>Returns a
CodePointMapRangestruct which represents a range of code points associated with the same trie value. The returned range will be the longest stretch of consecutive code points starting atstartthat share this value.This method is designed to use the internal details of the structure of
CodePointTrieto be optimally efficient. This will outperform a naive approach that just uses [CodePointTrie::get()].This method provides lower-level functionality that can be used in the implementation of other methods that are more convenient to the user. To obtain an optimal partition of the code point space for this trie resulting in the fewest number of ranges, see [
CodePointTrie::iter_ranges()].Examples
use planes; let trie = get_planes_trie; const CODE_POINT_MAX: u32 = 0x10ffff; let start = 0x1_0000; let exp_end = 0x1_ffff; let start_val = trie.get32; assert_eq!; assert_ne!; use CodePointMapRange; let cpm_range: = trie.get_range.unwrap; assert_eq!; assert_eq!; assert_eq!; // `start` can be any code point, whether or not it lies on the boundary // of a maximally large range that still contains `start` let submaximal_1_start = start + 0x1234; let submaximal_1 = trie.get_range.unwrap; assert_eq!; assert_eq!; assert_eq!; let submaximal_2_start = start + 0xffff; let submaximal_2 = trie.get_range.unwrap; assert_eq!; assert_eq!; assert_eq!;fn iter_ranges(self: &Self) -> CodePointMapRangeIterator<'_, T>Yields an
Iteratorreturning ranges of consecutive code points that share the same value in theCodePointTrie, as given by [CodePointTrie::get_range()].Examples
use RangeInclusive; use planes; use CodePointMapRange; let planes_trie = get_planes_trie; let mut ranges = planes_trie.iter_ranges; for plane in 0..=16 // Hitting the end of the iterator returns `None`, as will subsequent // calls to .next(). assert_eq!; assert_eq!;fn iter_ranges_for_value(self: &Self, value: T) -> impl Iterator<Item = RangeInclusive<u32>> + '_Yields an
Iteratorreturning the ranges of the code points whose values matchvaluein theCodePointTrie.Examples
use planes; let trie = get_planes_trie; let plane_val = 2; let mut sip_range_iter = trie.iter_ranges_for_value; let start = plane_val * 0x1_0000; let end = start + 0xffff; let sip_range = sip_range_iter.next .expect; assert_eq!; assert!;fn iter_ranges_mapped<'a, U: Eq + 'a, impl FnMut(T) -> U + Copy + 'a: FnMut(T) -> U + Copy + 'a>(self: &'a Self, map: impl FnMut(T) -> U + Copy + 'a) -> impl Iterator<Item = CodePointMapRange<U>> + 'aYields an
Iteratorreturning the ranges of the code points after passing the value through a mapping function.This is preferable to calling
.get_ranges().map()since it will coalesce adjacent ranges into one.Examples
use planes; let trie = get_planes_trie; let plane_val = 2; let mut sip_range_iter = trie.iter_ranges_mapped.filter; let end = plane_val * 0x1_0000 - 1; let sip_range = sip_range_iter.next .expect; assert_eq!;fn error_value(self: &Self) -> TReturns the value used as an error value for this trie
impl<T: TrieValue + Into<u32>> CodePointTrie<'_, T>
fn get32_u32(self: &Self, code_point: u32) -> u32Returns the value that is associated with
code_pointfor thisCodePointTrieas au32.Examples
use planes; let trie = get_planes_trie; let cp = '𑖎' as u32; assert_eq!; let plane_num: u8 = trie.get32; assert_eq!;
impl<'a, T> Yokeable for CodePointTrie<'static, T>
fn transform(self: &'a Self) -> &'a <Self as >::Outputfn transform_owned(self: Self) -> <Self as >::Outputunsafe fn make(this: <Self as >::Output) -> Selffn transform_mut<F>(self: &'a mut Self, f: F) where F: 'static + for<'b> FnOnce(&'b mut <Self as >::Output)
impl<'trie, T> Freeze for CodePointTrie<'trie, T>
impl<'trie, T> RefUnwindSafe for CodePointTrie<'trie, T>
impl<'trie, T> Send for CodePointTrie<'trie, T>
impl<'trie, T> Sync for CodePointTrie<'trie, T>
impl<'trie, T> Unpin for CodePointTrie<'trie, T>
impl<'trie, T> UnsafeUnpin for CodePointTrie<'trie, T>
impl<'trie, T> UnwindSafe for CodePointTrie<'trie, T>
impl<'trie, T: $crate::cmp::Eq + TrieValue> Eq for CodePointTrie<'trie, T>
impl<'trie, T: $crate::cmp::PartialEq + TrieValue> PartialEq for CodePointTrie<'trie, T>
fn eq(self: &Self, other: &CodePointTrie<'trie, T>) -> bool
impl<'trie, T: $crate::fmt::Debug + TrieValue> Debug for CodePointTrie<'trie, T>
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl<'trie, T: TrieValue> StructuralPartialEq for CodePointTrie<'trie, T>
impl<'zf, 'zf_inner, T: TrieValue> ZeroFrom for CodePointTrie<'zf, T>
fn zero_from(this: &'zf CodePointTrie<'zf_inner, T>) -> Self
impl<T> Any for CodePointTrie<'trie, T>
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for CodePointTrie<'trie, T>
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for CodePointTrie<'trie, T>
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> CloneToUninit for CodePointTrie<'trie, T>
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)
impl<T> ErasedDestructor for CodePointTrie<'trie, T>
impl<T> From for CodePointTrie<'trie, T>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for CodePointTrie<'trie, T>
fn to_owned(self: &Self) -> Tfn clone_into(self: &Self, target: &mut T)
impl<T, U> Into for CodePointTrie<'trie, T>
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for CodePointTrie<'trie, T>
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for CodePointTrie<'trie, T>
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>
impl<T: TrieValue> Clone for CodePointTrie<'_, T>
fn clone(self: &Self) -> Self