Struct regex_automata::nfa::thompson::map::Utf8SuffixMap

source ·
pub struct Utf8SuffixMap {
    version: u16,
    capacity: usize,
    map: Vec<Utf8SuffixEntry>,
}
Expand description

A cache of suffixes used to modestly compress UTF-8 automata for large Unicode character classes.

Fields§

§version: u16

The current version of this map. Only entries with matching versions are considered during lookups. If an entry is found with a mismatched version, then the map behaves as if the entry does not exist.

§capacity: usize

The total number of entries this map can store.

§map: Vec<Utf8SuffixEntry>

The actual entries, keyed by hash. Collisions between different states result in the old state being dropped.

Implementations§

source§

impl Utf8SuffixMap

source

pub fn new(capacity: usize) -> Utf8SuffixMap

Create a new bounded map with the given capacity. The map will never grow beyond the given size.

Note that this does not allocate. Instead, callers must call clear before using this map. clear will allocate space if necessary.

This avoids the need to pay for the allocation of this map when compiling regexes that lack large Unicode character classes.

source

pub fn clear(&mut self)

Clear this map of all entries, but permit the reuse of allocation if possible.

This must be called before the map can be used.

source

pub fn hash(&self, key: &Utf8SuffixKey) -> usize

Return a hash of the given transition.

source

pub fn get(&mut self, key: &Utf8SuffixKey, hash: usize) -> Option<StateID>

Retrieve the cached state ID corresponding to the given key. The hash given must have been computed with hash using the same key value.

If there is no cached state with the given key, then None is returned.

source

pub fn set(&mut self, key: Utf8SuffixKey, hash: usize, state_id: StateID)

Add a cached state to this map with the given key. Callers should ensure that state_id points to a state that contains precisely the NFA transition given.

hash must have been computed using the hash method with the same key.

Trait Implementations§

source§

impl Clone for Utf8SuffixMap

source§

fn clone(&self) -> Utf8SuffixMap

Returns a copy 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 Debug for Utf8SuffixMap

source§

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

Formats the value using the given formatter. 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> 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,

§

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>,

§

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>,

§

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.