Struct regex_automata::util::alphabet::ByteClassSet

source ·
pub(crate) struct ByteClassSet(ByteSet);
Expand description

A partitioning of bytes into equivalence classes.

A byte class set keeps track of an approximation of equivalence classes of bytes during NFA construction. That is, every byte in an equivalence class cannot discriminate between a match and a non-match.

For example, in the regex [ab]+, the bytes a and b would be in the same equivalence class because it never matters whether an a or a b is seen, and no combination of as and bs in the text can discriminate a match.

Note though that this does not compute the minimal set of equivalence classes. For example, in the regex [ac]+, both a and c are in the same equivalence class for the same reason that a and b are in the same equivalence class in the aforementioned regex. However, in this implementation, a and c are put into distinct equivalence classes. The reason for this is implementation complexity. In the future, we should endeavor to compute the minimal equivalence classes since they can have a rather large impact on the size of the DFA. (Doing this will likely require rethinking how equivalence classes are computed, including changing the representation here, which is only able to group contiguous bytes into the same equivalence class.)

Tuple Fields§

§0: ByteSet

Implementations§

source§

impl ByteClassSet

source

pub(crate) fn empty() -> Self

Create a new set of byte classes where all bytes are part of the same equivalence class.

source

pub(crate) fn set_range(&mut self, start: u8, end: u8)

Indicate the range of byte given (inclusive) can discriminate a match between it and all other bytes outside of the range.

source

pub(crate) fn add_set(&mut self, set: &ByteSet)

Add the contiguous ranges in the set given to this byte class set.

source

pub(crate) fn byte_classes(&self) -> ByteClasses

Convert this boolean set to a map that maps all byte values to their corresponding equivalence class. The last mapping indicates the largest equivalence class identifier (which is never bigger than 255).

Trait Implementations§

source§

impl Clone for ByteClassSet

source§

fn clone(&self) -> ByteClassSet

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 ByteClassSet

source§

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

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

impl Default for ByteClassSet

source§

fn default() -> ByteClassSet

Returns the “default value” for a type. 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.