Struct zerotrie::cursor::ZeroAsciiIgnoreCaseTrieCursor
source · pub struct ZeroAsciiIgnoreCaseTrieCursor<'a> {
trie: ZeroAsciiIgnoreCaseTrie<&'a [u8]>,
}
Expand description
A cursor into a ZeroAsciiIgnoreCaseTrie
, useful for stepwise lookup.
For examples, see ZeroAsciiIgnoreCaseTrie::cursor()
.
Fields§
§trie: ZeroAsciiIgnoreCaseTrie<&'a [u8]>
Implementations§
source§impl<'a> ZeroAsciiIgnoreCaseTrieCursor<'a>
impl<'a> ZeroAsciiIgnoreCaseTrieCursor<'a>
sourcepub fn step(&mut self, byte: u8) -> Option<u8>
pub fn step(&mut self, byte: u8) -> Option<u8>
Steps the cursor one byte into the trie.
Returns the byte if matched, which may be a different case than the input byte.
If this function returns None
, any lookup loops can be terminated.
§Examples
Normalize the case of a value by stepping through an ignore-case trie:
use std::borrow::Cow;
use zerotrie::ZeroAsciiIgnoreCaseTrie;
// A trie with two values: "aBc" and "aBcdEf"
let trie = ZeroAsciiIgnoreCaseTrie::from_bytes(b"aBc\x80dEf\x81");
// Get out the value for "abc" and normalize the key string
let mut cursor = trie.cursor();
let mut key_str = Cow::Borrowed("abc".as_bytes());
let mut i = 0;
let value = loop {
let Some(&input_byte) = key_str.get(i) else {
break cursor.take_value();
};
let Some(matched_byte) = cursor.step(input_byte) else {
break None;
};
if matched_byte != input_byte {
key_str.to_mut()[i] = matched_byte;
}
i += 1;
};
assert_eq!(value, Some(0));
assert_eq!(&*key_str, "aBc".as_bytes());
For more examples, see ZeroTrieSimpleAsciiCursor::step
.
sourcepub fn take_value(&mut self) -> Option<usize>
pub fn take_value(&mut self) -> Option<usize>
Takes the value at the current position.
For more details, see ZeroTrieSimpleAsciiCursor::take_value
.
sourcepub fn probe(&mut self, index: usize) -> Option<AsciiProbeResult>
pub fn probe(&mut self, index: usize) -> Option<AsciiProbeResult>
Probes the next byte in the cursor.
For more details, see ZeroTrieSimpleAsciiCursor::probe
.
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Checks whether the cursor points to an empty trie.
For more details, see ZeroTrieSimpleAsciiCursor::is_empty
.
Trait Implementations§
source§impl<'a> Clone for ZeroAsciiIgnoreCaseTrieCursor<'a>
impl<'a> Clone for ZeroAsciiIgnoreCaseTrieCursor<'a>
source§fn clone(&self) -> ZeroAsciiIgnoreCaseTrieCursor<'a>
fn clone(&self) -> ZeroAsciiIgnoreCaseTrieCursor<'a>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<'a> Debug for ZeroAsciiIgnoreCaseTrieCursor<'a>
impl<'a> Debug for ZeroAsciiIgnoreCaseTrieCursor<'a>
source§impl<'a> Write for ZeroAsciiIgnoreCaseTrieCursor<'a>
impl<'a> Write for ZeroAsciiIgnoreCaseTrieCursor<'a>
source§fn write_str(&mut self, s: &str) -> Result
fn write_str(&mut self, s: &str) -> Result
Steps the cursor through each ASCII byte of the string.
If the string contains non-ASCII chars, an error is returned.
source§fn write_char(&mut self, c: char) -> Result
fn write_char(&mut self, c: char) -> Result
Equivalent to ZeroAsciiIgnoreCaseTrieCursor::step()
, except returns
an error if the char is non-ASCII.
Auto Trait Implementations§
impl<'a> Freeze for ZeroAsciiIgnoreCaseTrieCursor<'a>
impl<'a> RefUnwindSafe for ZeroAsciiIgnoreCaseTrieCursor<'a>
impl<'a> Send for ZeroAsciiIgnoreCaseTrieCursor<'a>
impl<'a> Sync for ZeroAsciiIgnoreCaseTrieCursor<'a>
impl<'a> Unpin for ZeroAsciiIgnoreCaseTrieCursor<'a>
impl<'a> UnwindSafe for ZeroAsciiIgnoreCaseTrieCursor<'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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)