pub struct ZeroAsciiIgnoreCaseTrieCursor<'a> { /* private fields */ }
Expand description
A cursor into a ZeroAsciiIgnoreCaseTrie
, useful for stepwise lookup.
For examples, see ZeroAsciiIgnoreCaseTrie::cursor()
.
Implementations§
Source§impl ZeroAsciiIgnoreCaseTrieCursor<'_>
impl ZeroAsciiIgnoreCaseTrieCursor<'_>
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 Write for ZeroAsciiIgnoreCaseTrieCursor<'_>
impl Write for ZeroAsciiIgnoreCaseTrieCursor<'_>
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,
impl<T> ErasedDestructor for Twhere
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: 16 bytes