pub struct Char16TrieCursor<'a> { /* private fields */ }Expand description
A cursor into a Char16Trie, useful for stepwise lookup.
Implementations§
Source§impl<'a> Char16TrieCursor<'a>
impl<'a> Char16TrieCursor<'a>
Sourcepub fn new(trie: &'a ZeroSlice<u16>) -> Self
pub fn new(trie: &'a ZeroSlice<u16>) -> Self
Returns a new Char16TrieCursor backed by borrowed data for the trie array.
Sourcepub fn step(&mut self, c: char)
pub fn step(&mut self, c: char)
Steps the cursor one char into the trie.
§Examples
use icu::collections::char16trie::Char16Trie;
use zerovec::ZeroVec;
// A Char16Trie containing the ASCII characters 'a' and 'ab'.
let trie_data = [48, 97, 176, 98, 32868];
let trie = Char16Trie::new(ZeroVec::from_slice_or_alloc(&trie_data));
let mut cursor = trie.cursor();
cursor.step('a');
assert_eq!(cursor.value(), Some(1));
assert!(!cursor.is_empty());
cursor.step('b');
assert_eq!(cursor.value(), Some(100));
assert!(cursor.is_empty());
cursor.step('c');
assert_eq!(cursor.value(), None);
assert!(cursor.is_empty());Sourcepub fn step32(&mut self, c: u32)
pub fn step32(&mut self, c: u32)
Steps the cursor one code point (up to 0x10ffff) into the trie.
§Examples
use icu::collections::char16trie::Char16Trie;
use zerovec::ZeroVec;
// A Char16Trie containing the ASCII characters 'a' and 'ab'.
let trie_data = [48, 97, 176, 98, 32868];
let trie = Char16Trie::new(ZeroVec::from_slice_or_alloc(&trie_data));
let mut cursor = trie.cursor();
cursor.step32('a' as u32);
assert_eq!(cursor.value(), Some(1));
assert!(!cursor.is_empty());
cursor.step32('b' as u32);
assert_eq!(cursor.value(), Some(100));
assert!(cursor.is_empty());
cursor.step32('c' as u32);
assert_eq!(cursor.value(), None);
assert!(cursor.is_empty());Sourcepub fn step16(&mut self, c: u16)
pub fn step16(&mut self, c: u16)
Steps the cursor one 16-bit code unit into the trie.
§Examples
use icu::collections::char16trie::Char16Trie;
use zerovec::ZeroVec;
// A Char16Trie containing the ASCII characters 'a' and 'ab'.
let trie_data = [48, 97, 176, 98, 32868];
let trie = Char16Trie::new(ZeroVec::from_slice_or_alloc(&trie_data));
let mut cursor = trie.cursor();
cursor.step16('a' as u16);
assert_eq!(cursor.value(), Some(1));
assert!(!cursor.is_empty());
cursor.step16('b' as u16);
assert_eq!(cursor.value(), Some(100));
assert!(cursor.is_empty());
cursor.step16('c' as u16);
assert_eq!(cursor.value(), None);
assert!(cursor.is_empty());Trait Implementations§
Source§impl<'a> Clone for Char16TrieCursor<'a>
impl<'a> Clone for Char16TrieCursor<'a>
Source§impl<'a> Debug for Char16TrieCursor<'a>
impl<'a> Debug for Char16TrieCursor<'a>
Auto Trait Implementations§
impl<'a> Freeze for Char16TrieCursor<'a>
impl<'a> RefUnwindSafe for Char16TrieCursor<'a>
impl<'a> Send for Char16TrieCursor<'a>
impl<'a> Sync for Char16TrieCursor<'a>
impl<'a> Unpin for Char16TrieCursor<'a>
impl<'a> UnsafeUnpin for Char16TrieCursor<'a>
impl<'a> UnwindSafe for Char16TrieCursor<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more