Struct ZeroAsciiIgnoreCaseTrieCursor

struct ZeroAsciiIgnoreCaseTrieCursor<'a> { ... }

A cursor into a ZeroAsciiIgnoreCaseTrie, useful for stepwise lookup.

For examples, see [ZeroAsciiIgnoreCaseTrie::cursor()].

Implementations

impl ZeroAsciiIgnoreCaseTrieCursor<'_>

fn step(self: &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.

fn take_value(self: &mut Self) -> Option<usize>

Takes the value at the current position.

For more details, see ZeroTrieSimpleAsciiCursor::take_value.

fn probe(self: &mut Self, index: usize) -> Option<AsciiProbeResult>

Probes the next byte in the cursor.

For more details, see ZeroTrieSimpleAsciiCursor::probe.

fn is_empty(self: &Self) -> bool

Checks whether the cursor points to an empty trie.

For more details, see ZeroTrieSimpleAsciiCursor::is_empty.

impl Write for ZeroAsciiIgnoreCaseTrieCursor<'_>

fn write_str(self: &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.

fn write_char(self: &mut Self, c: char) -> Result

Equivalent to [ZeroAsciiIgnoreCaseTrieCursor::step()], except returns an error if the char is non-ASCII.

impl<'a> Clone for ZeroAsciiIgnoreCaseTrieCursor<'a>

fn clone(self: &Self) -> ZeroAsciiIgnoreCaseTrieCursor<'a>

impl<'a> Debug for ZeroAsciiIgnoreCaseTrieCursor<'a>

fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result

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> UnsafeUnpin for ZeroAsciiIgnoreCaseTrieCursor<'a>

impl<'a> UnwindSafe for ZeroAsciiIgnoreCaseTrieCursor<'a>

impl<T> Any for ZeroAsciiIgnoreCaseTrieCursor<'a>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for ZeroAsciiIgnoreCaseTrieCursor<'a>

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for ZeroAsciiIgnoreCaseTrieCursor<'a>

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> CloneToUninit for ZeroAsciiIgnoreCaseTrieCursor<'a>

unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)

impl<T> ErasedDestructor for ZeroAsciiIgnoreCaseTrieCursor<'a>

impl<T> From for ZeroAsciiIgnoreCaseTrieCursor<'a>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for ZeroAsciiIgnoreCaseTrieCursor<'a>

fn to_owned(self: &Self) -> T
fn clone_into(self: &Self, target: &mut T)

impl<T, U> Into for ZeroAsciiIgnoreCaseTrieCursor<'a>

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom for ZeroAsciiIgnoreCaseTrieCursor<'a>

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for ZeroAsciiIgnoreCaseTrieCursor<'a>

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>