ZeroAsciiIgnoreCaseTrieCursor

Struct ZeroAsciiIgnoreCaseTrieCursor 

Source
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<'_>

Source

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.

Source

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

Takes the value at the current position.

For more details, see ZeroTrieSimpleAsciiCursor::take_value.

Source

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

Probes the next byte in the cursor.

For more details, see ZeroTrieSimpleAsciiCursor::probe.

Source

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>

Source§

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

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

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

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Write for ZeroAsciiIgnoreCaseTrieCursor<'_>

Source§

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

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

1.0.0 · Source§

fn write_fmt(&mut self, args: Arguments<'_>) -> Result<(), Error>

Glue for usage of the write! macro with implementors of this trait. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

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

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where 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