Skip to main content

RegexInput

Struct RegexInput 

Source
pub struct RegexInput<'h, S: Input + ?Sized> { /* private fields */ }
Expand description

A search configuration for matching against a haystack.

This keeps the original haystack together with a starting search position and a range that constrains where the overall match may occur. Unlike slicing a haystack, anchors and lookaround can still inspect the full original input, and reported offsets remain absolute.

Implementations§

Source§

impl<'h, S: Input + ?Sized> RegexInput<'h, S>

Source

pub fn new(haystack: &'h S) -> Self

Create a new search input over the full haystack.

Source

pub fn haystack(&self) -> &'h S

Return the haystack being searched.

Source

pub fn start(&self) -> usize

Return the requested starting position for this search.

Source

pub fn get_range(&self) -> Range<usize>

Return the range constraining where match 0 may occur.

Source

pub fn from_pos(self, start: usize) -> Self

Return a copy of this input with a different search start.

Source

pub fn range(self, range: Range<usize>) -> Self

Return a copy of this input with a different search range.

§Panics

Panics if the range is not within the haystack bounds or if range.start > range.end.

Source

pub fn start_text(self, yes: bool) -> Self

Return a copy of this input with an override for whether ^/\A should match.

This override is suppression-only: false suppresses the assertion, while true clears the override and preserves default behavior.

Source

pub fn end_text(self, yes: bool) -> Self

Return a copy of this input with an override for whether $/\z should match.

This override is suppression-only: false suppresses the assertion, while true clears the override and preserves default behavior.

Source

pub fn continue_from_previous_match_end(self, yes: bool) -> Self

Return a copy of this input with an override for whether \G should match.

This override is suppression-only: false suppresses the assertion, while true clears the override and preserves default behavior.

Source

pub fn anchored(self, yes: bool) -> Self

Return a copy of this input with an override for whether matching should be anchored at the start position.

When true, the regex will only match at the exact start position, without scanning forward through the haystack. This is more efficient when you already know where a potential match must occur.

Trait Implementations§

Source§

impl<'h, S: Input + ?Sized> Clone for RegexInput<'h, S>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<'h, S: Debug + Input + ?Sized> Debug for RegexInput<'h, S>

Source§

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

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

impl<'h, S: Input + ?Sized> From<&'h S> for RegexInput<'h, S>

Source§

fn from(haystack: &'h S) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'h, S> Freeze for RegexInput<'h, S>
where S: ?Sized,

§

impl<'h, S> RefUnwindSafe for RegexInput<'h, S>
where S: RefUnwindSafe + ?Sized,

§

impl<'h, S> Send for RegexInput<'h, S>
where S: Sync + ?Sized,

§

impl<'h, S> Sync for RegexInput<'h, S>
where S: Sync + ?Sized,

§

impl<'h, S> Unpin for RegexInput<'h, S>
where S: ?Sized,

§

impl<'h, S> UnsafeUnpin for RegexInput<'h, S>
where S: ?Sized,

§

impl<'h, S> UnwindSafe for RegexInput<'h, S>
where S: RefUnwindSafe + ?Sized,

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.