Enum regex_automata::util::start::Start

source ·
pub(crate) enum Start {
    NonWordByte = 0,
    WordByte = 1,
    Text = 2,
    LineLF = 3,
    LineCR = 4,
    CustomLineTerminator = 5,
}
Expand description

Represents the six possible starting configurations of a DFA search.

The starting configuration is determined by inspecting the beginning of the haystack (up to 1 byte). Ultimately, this along with a pattern ID (if specified) and the type of search (anchored or not) is what selects the start state to use in a DFA.

As one example, if a DFA only supports unanchored searches and does not support anchored searches for each pattern, then it will have at most 6 distinct start states. (Some start states may be reused if determinization can determine that they will be equivalent.) If the DFA supports both anchored and unanchored searches, then it will have a maximum of 12 distinct start states. Finally, if the DFA also supports anchored searches for each pattern, then it can have up to 12 + (N * 6) start states, where N is the number of patterns.

Handling each of these starting configurations in the context of DFA determinization can be quite tricky and subtle. But the code is small and can be found at crate::util::determinize::set_lookbehind_from_start.

Variants§

§

NonWordByte = 0

This occurs when the starting position is not any of the ones below.

§

WordByte = 1

This occurs when the byte immediately preceding the start of the search is an ASCII word byte.

§

Text = 2

This occurs when the starting position of the search corresponds to the beginning of the haystack.

§

LineLF = 3

This occurs when the byte immediately preceding the start of the search is a line terminator. Specifically, \n.

§

LineCR = 4

This occurs when the byte immediately preceding the start of the search is a line terminator. Specifically, \r.

§

CustomLineTerminator = 5

This occurs when a custom line terminator has been set via a LookMatcher, and when that line terminator is neither a \r or a \n.

If the custom line terminator is a word byte, then this start configuration is still selected. DFAs that implement word boundary assertions will likely need to check whether the custom line terminator is a word byte, in which case, it should behave as if the byte satisfies \b in addition to multi-line anchors.

Implementations§

source§

impl Start

source

pub(crate) fn from_usize(n: usize) -> Option<Start>

Return the starting state corresponding to the given integer. If no starting state exists for the given integer, then None is returned.

source

pub(crate) fn len() -> usize

Returns the total number of starting state configurations.

source

pub(crate) fn as_u8(&self) -> u8

Return this starting configuration as u8 integer. It is guaranteed to be less than Start::len().

source

pub(crate) fn as_usize(&self) -> usize

Return this starting configuration as a usize integer. It is guaranteed to be less than Start::len().

Trait Implementations§

source§

impl Clone for Start

source§

fn clone(&self) -> Start

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 Start

source§

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

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

impl PartialEq for Start

source§

fn eq(&self, other: &Start) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for Start

source§

impl Eq for Start

source§

impl StructuralPartialEq for Start

Auto Trait Implementations§

§

impl Freeze for Start

§

impl RefUnwindSafe for Start

§

impl Send for Start

§

impl Sync for Start

§

impl Unpin for Start

§

impl UnwindSafe for Start

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.