Skip to main content

RegexSet

Struct RegexSet 

Source
pub struct RegexSet { /* private fields */ }
Expand description

A multi-pattern set: which patterns match the subject at least once (which-matched).

Mirrors the regex crate’s RegexSet. Bitset order is the construction order of the patterns. Captures are not reported — re-run the individual pattern if groups are needed. Stage-1 is N independent walks with per-pattern early-exit (not a fused single-pass automaton).

Implementations§

Source§

impl RegexSet

Source

pub fn new<I, S>(patterns: I) -> Result<RegexSet, Error>
where I: IntoIterator<Item = S>, S: AsRef<str>,

Compile every pattern; fails if any pattern is invalid (no silent skip).

Source

pub fn with_flags<I, S>(patterns: I, flags: u32) -> Result<RegexSet, Error>
where I: IntoIterator<Item = S>, S: AsRef<str>,

Compile with a real::flags bitmask (same bits as Regex::with_flags).

Source

pub fn len(&self) -> usize

Number of patterns in the set.

Source

pub fn is_empty(&self) -> bool

Whether the set has no patterns.

Source

pub fn patterns(&self) -> &[String]

The original pattern strings (construction order).

Source

pub fn is_match(&self, text: &str) -> bool

True if any pattern matches text (stops at the first hit).

Source

pub fn matches(&self, text: &str) -> Vec<bool>

Which patterns match at least once: bitset of length len, construction order. Index i is true iff pattern i matched.

Source

pub fn matched_ids(&self, text: &str) -> Vec<usize>

Indices of matching patterns (ascending, construction order).

Trait Implementations§

Source§

impl Drop for RegexSet

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Send for RegexSet

Source§

impl Sync for RegexSet

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